我正在用gwt做一個項目。我必須使用Eclipse Luna,JUnit和Mockito測試演示者,並且在執行任何操作時遇到問題。Gwt Mockito:@RunWith(GwtMockitoTestRunner.class)導致異常
當我用mockito失敗後,我發現了GwtMockito並嘗試過。我用這個例子開始:Github GwtMockito example
我的測試類是這樣的:
@RunWith(GwtMockitoTestRunner.class)
public class GamePresenterTest {
@GwtMock private GameServiceAsync gameService;
@GwtMock private LobbyPresenter lobbyPresenter;
@GwtMock private EventBus eventBus;
@GwtMock private Display gameView;
@GwtMock private User user;
@GwtMock private Player player;
@GwtMock private ClickEvent event;
private GamePresenter presenter;
private String username = "name";
private String gameTitle = "title";
@Before
public void setUp() {
System.out.println("TODO: set up");
}
@Test
public void testActionTableClicked() {
System.out.println("TODO: add test");
}
}
當我運行它,我得到這個
java.lang.NoClassDefFoundError: javassist/NotFoundException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
at java.lang.Class.getConstructor0(Class.java:3075)
at java.lang.Class.getConstructor(Class.java:1825)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:29)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:21)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:26)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:33)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:48)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:444)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: java.lang.ClassNotFoundException: javassist.NotFoundException
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 18 more
當我刪除了@RunWith(GwtMockitoTestRunner.class)
我得到另一個消息這告訴我我應該使用initMocks,但我也不怎麼這樣做。 沒有@RunWith(GwtMockitoTestRunner.class)
和@GwtMock
東西一切工作正常,當然。
我希望有人能幫忙,因爲我的項目在幾個星期內結束。
得到一個像maven一樣的依賴管理工具。 – keuleJ