3

我的 GwtTestWithMockito 派生测试在 Eclipse 中运行良好。

当使用 maven 从命令行运行时,每个测试都会在初始化时抛出以下堆栈跟踪:

Forking command line: /bin/sh -c cd /home/mirk/repo/aftd/aftdweb && /usr/local/java/jdk1.7.0_05/jre/bin/java -Xmx1024M -Xss512M -XX:MaxPermSize=128M org.apache.maven.surefire.booter.ForkedBooter /home/dirk/repo/aftd/aftdweb/target/surefire/surefire2771679869724775356tmp /home/dirk/repo/aftd/aftdweb/target/surefire/surefire_08727036010322995493tmp
Running de.telekom.aftd.web.client.presenter.menu.GwtTestWithMockitoCompanyLevelPresenter
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 7.077 sec <<< FAILURE!
initializationError(de.telekom.aftd.web.client.presenter.menu.GwtTestWithMockitoCompanyLevelPresenter)  Time elapsed: 0.01 sec  <<< ERROR!
java.lang.ClassCastException: com.googlecode.gwt.test.internal.junit.GwtBlockJUnit4ClassRunner cannot be cast to org.junit.runner.Runner
    at com.googlecode.gwt.test.internal.junit.AbstractGwtRunnerFactory.newInstance(AbstractGwtRunnerFactory.java:64)
    at com.googlecode.gwt.test.internal.junit.AbstractGwtRunnerFactory.create(AbstractGwtRunnerFactory.java:42)
    at com.googlecode.gwt.test.internal.junit.AbstractGwtRunner.<init>(AbstractGwtRunner.java:31)
    at com.googlecode.gwt.test.GwtRunner.<init>(GwtRunner.java:19)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
    at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31)
    at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:262)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
    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:601)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray2(ReflectionUtils.java:208)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:158)
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:86)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:95)


Results :

   » ClassCast com.googlecode.gwt.test.internal.junit.GwtBlockJUnit4ClassRunner ...

我正在使用 gwt 2.5.0、gwt-test-utils 0.44、mockito-core 1.9.5。

我可以提供更多细节,但我不确定还有什么需要。

编辑:

这是我在 maven-surefire-plugin 中以 java 模式运行它们时遇到的错误。我认为这是由于 gwt 与 junit 3 一起发货,而 mockito 期待 junit 4。

4

0 回答 0