alibaba / otter

阿里巴巴分布式数据库同步系统(解决中美异地机房)
Apache License 2.0
8.08k stars 2.49k forks source link

otter 里面的单元测试运行报错 #487

Closed lralin closed 5 years ago

lralin commented 6 years ago

java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:382) at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:397) 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:224) at mockit.internal.RedefinitionEngine.modifyRealClass(RedefinitionEngine.java:201) at mockit.internal.RedefinitionEngine.redefineMethods(RedefinitionEngine.java:185) at mockit.internal.RedefinitionEngine.setUpStartupMock(RedefinitionEngine.java:161) at mockit.internal.startup.Startup.setUpInternalStartupMock(Startup.java:175) at mockit.internal.startup.Startup.loadInternalStartupMocks(Startup.java:155) at mockit.internal.startup.Startup.initialize(Startup.java:133) at mockit.internal.startup.Startup.premain(Startup.java:117) ... 6 more FATAL ERROR in native method: processing of -javaagent failed Exception in thread "main"

lralin commented 6 years ago

@agapple

agapple commented 6 years ago

需要有一个testng插件

lralin commented 6 years ago

idea 自带testng插件的。

Martian101 commented 6 years ago

@lralin 我遇到类似的问题,后来发现项目里不知为什么有时候maven更新会自动引入0.999.4版本的jmockit,更新下来后跑单元测试用的也是这个版本而不是pom里指定的0.999.10。把系统里的0.999.4版本清掉之后运行就正常了。怀疑应该是两个Jar包mockit.internal.startup.Startup 类的实现不同,0.999.4的版本会加载TestNGTestRunnerDecorator导致报错, 0.999.4版本有如下实现:

   private static void loadInternalStartupMocks()
   {
      setUpInternalStartupMock(TestSuiteDecorator.class);
      setUpInternalStartupMock(JUnitTestCaseDecorator.class);

      setUpInternalStartupMock(RunNotifierDecorator.class);
      setUpInternalStartupMock(BlockJUnit4ClassRunnerDecorator.class);

      setUpInternalStartupMock(TestNGTestRunnerDecorator.class); //加载报错

      TestRun.mockFixture().turnRedefinedClassesIntoFixedOnes();
   }
liulangwa commented 5 years ago

官方仓库里没有0.999.10,lib/install.sh导入库里 mvn clean install 找不到这个0.999.10的依赖