TestNG导致Test运行不了
来源:互联网 发布:python策略模型 编辑:程序博客网 时间:2024/05/04 00:37
解决因为TestNG插件导致eclipse无法跑jtester的问题
- 博客分类:
- Java
EclipseJava单元测试SUNJDK
笔者按:
这个是一篇老文了,之前解决出来发到邮件群里了,换了笔记本发现邮件没有了。今天不经意间又发现了,防止再次失踪,于是记录到博客里,以作备案。
关于什么是jtester,可以看下这个论坛贴子。
http://www.iteye.com/topic/900975
正文:
笔者今日发现,自己新装Eclipse3.5,下载的JTester工程,装了TestNG插件,写一个JTester的单元测试。
但运行都报错了。其他同事运行的单元测试却没有问题,觉得奇怪。刚开始怀疑是JDK问题,
我下载了JDK1.6.0.17,JDK1.6.0.20,JDK1.6.0.22都不行。还是报同样的错误:
现象:
分析:
我通过DEBUG代码,发现在jtester包中的Startup类中执行loadInternalStartupMocks方法里报错具体在这一行:
JTester在启动时设置各个测试框架的Mock时,唯独TestNG的报错了。于是我开始验证,
1.建立继承以Junit4的JTester的测试类,可以正常运行;
2.单独建立基类是TestNG也可以运行
3.建立扩展以TestNG为基础的JTester无法运行。
所以,我得出结论,当前TestNG插件版本与JTester是不兼容的。
我检查了自己运行的TestNG插件版本,在Eclipse这里查看:(图中的TestNG笔者已经卸载掉)
验证:
发现TestNG版本是5.14.2.9。该版本是通过eclipse中的install new software 中http://beust.com/eclipse这个地址下载。
而其他同事(运行正常)的版本是:5.14.0.1,或者5.13.x。
于是我先点击Uninstall将TestNG版本删除,退出eclipse,到eclipse的安装目录,将plugins中的org.testng.eclipse_5.14.2.9的目录删除(这样才能彻底删除)。
再从http://testng.org/testng-eclipse-5.14.0.1.zip这里下载。将其解压,拷贝到plugins目录下。你 也可以使用附件中jar文件,将他拷贝到eclipse安装目录下的plugins中。安装重启Eclipse,之后再运行单元测试,JTester又出现了绿色!
总结:
如果你要开始使用JTester,请不要使用http://beust.com/eclipse的Update方式下载TestNG插件,直接使用org.testng.eclipse_5.14.0.1.jar文件。
这个是一篇老文了,之前解决出来发到邮件群里了,换了笔记本发现邮件没有了。今天不经意间又发现了,防止再次失踪,于是记录到博客里,以作备案。
关于什么是jtester,可以看下这个论坛贴子。
http://www.iteye.com/topic/900975
正文:
笔者今日发现,自己新装Eclipse3.5,下载的JTester工程,装了TestNG插件,写一个JTester的单元测试。
但运行都报错了。其他同事运行的单元测试却没有问题,觉得奇怪。刚开始怀疑是JDK问题,
我下载了JDK1.6.0.17,JDK1.6.0.20,JDK1.6.0.22都不行。还是报同样的错误:
现象:
- Setting connection parameters:127.0.0.1:39337
- init jmockit:true
- Exception in thread "Attach Listener" java.lang.reflect.InvocationTargetException
- at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
- at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
- at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
- at java.lang.reflect.Method.invoke(Method.java:597)
- at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:323)
- at sun.instrument.InstrumentationImpl.loadClassAndCallAgentmain(InstrumentationImpl.java:348)
- Caused by: java.lang.IllegalArgumentException: Matching real methods not found for the following mocks:
- Object invokeMethod(reflect.Method, Object, Object[])
- at mockit.internal.RedefinitionEngine.modifyRealClass(RedefinitionEngine.java:259)
- at mockit.internal.RedefinitionEngine.modifyRealClass(RedefinitionEngine.java:235)
- at mockit.internal.RedefinitionEngine.redefineMethods(RedefinitionEngine.java:209)
- at mockit.internal.RedefinitionEngine.setUpStartupMock(RedefinitionEngine.java:185)
- at mockit.internal.startup.Startup.setUpInternalStartupMock(Startup.java:181)
- at mockit.internal.startup.Startup.loadInternalStartupMocks(Startup.java:161)
- at mockit.internal.startup.Startup.initialize(Startup.java:139)
- at mockit.internal.startup.Startup.agentmain(Startup.java:128)
- ... 6 more
分析:
我通过DEBUG代码,发现在jtester包中的Startup类中执行loadInternalStartupMocks方法里报错具体在这一行:
- private static void loadInternalStartupMocks()
- {
- setUpInternalStartupMock(TestSuiteDecorator.class);
- setUpInternalStartupMock(JUnitTestCaseDecorator.class);
- setUpInternalStartupMock(RunNotifierDecorator.class);
- setUpInternalStartupMock(BlockJUnit4ClassRunnerDecorator.class);
- setUpInternalStartupMock(TestNGTestRunnerDecorator.class); //这里抛出了异常
- TestRun.mockFixture().turnRedefinedClassesIntoFixedOnes();
- }
JTester在启动时设置各个测试框架的Mock时,唯独TestNG的报错了。于是我开始验证,
1.建立继承以Junit4的JTester的测试类,可以正常运行;
2.单独建立基类是TestNG也可以运行
3.建立扩展以TestNG为基础的JTester无法运行。
所以,我得出结论,当前TestNG插件版本与JTester是不兼容的。
我检查了自己运行的TestNG插件版本,在Eclipse这里查看:(图中的TestNG笔者已经卸载掉)
验证:
发现TestNG版本是5.14.2.9。该版本是通过eclipse中的install new software 中http://beust.com/eclipse这个地址下载。
而其他同事(运行正常)的版本是:5.14.0.1,或者5.13.x。
于是我先点击Uninstall将TestNG版本删除,退出eclipse,到eclipse的安装目录,将plugins中的org.testng.eclipse_5.14.2.9的目录删除(这样才能彻底删除)。
再从http://testng.org/testng-eclipse-5.14.0.1.zip这里下载。将其解压,拷贝到plugins目录下。你 也可以使用附件中jar文件,将他拷贝到eclipse安装目录下的plugins中。安装重启Eclipse,之后再运行单元测试,JTester又出现了绿色!
总结:
如果你要开始使用JTester,请不要使用http://beust.com/eclipse的Update方式下载TestNG插件,直接使用org.testng.eclipse_5.14.0.1.jar文件。
- TestNG导致Test运行不了
- TestNG 五 运行TestNG
- test notation from testNG
- TestNG – Timeout Test
- TestNG指南4-运行TestNG
- TestNG·五 运行TestNG
- TestNG Priority in Test Cases
- maven运行testNG
- 命令行运行testNG
- testng+reportng,运行xml
- TestNG运行JUnit测试
- TestNG运行JUnit测试
- testNG注释运行顺序
- Maven运行TestNG
- TestNG运行JUnit测试
- ant运行testng
- TestNG官方文档中文版(4)-运行TestNG
- TestNG系列-第三章 testNG运行方法
- Hibernate3的DetachedCriteria使用
- 背包问题——“完全背包”最优方案总数分析及实现
- vs 2010 build qt 4.7 error(转)
- Python的MySQL库
- 依赖注入的介绍,不错的文章
- TestNG导致Test运行不了
- java
- Postgresql内存表
- 有关缓存,缓存算法,缓存框架:part 1
- 如何制作rpm包
- 有关缓存,缓存算法,缓存框架:part 2
- android模拟器 内存只读错误
- 字符识别(模板匹配&BP神经网络训练)
- websphere 连接 DB2 错误