2012-08-28 114 views
2

我已經創建測試用例一個Eclipse RCP應用程序:沒有可運行的方法,同時運行測試用例運行JUnit的插件測試

@Test 
public final void testIsCacertsFileExist() { 
    try {//URL url = new URL("https://server/web/services/WO"); 
    // System.out.println(url.getPort()); 
    URL url1 = new URL("http://server/web/services/WO"); 
    System.out.println(url1.getPort()); 
    CertificateHandler.addCertToKeyStore(
     "http://server/web/services/WO");", 443); 
    File file = new File("cacerts"); 
    Assert.assertTrue(file.exists()); 
    readCertificates(file); 
} catch (ConnectionException e) { 
    fail(e.getMessage()); 
} catch (MalformedURLException e) { 
    // TODO Auto-generated catch block 
    e.printStackTrace(); 
} 
} 

我使用@Test註解。 在Eclipse中我正在運行run as > Junit Plugin test。 不過我得到以下錯誤:

java.lang.Exception: No runnable methods 
    at org.junit.runners.BlockJUnit4ClassRunner.validateInstanceMethods(BlockJUnit4ClassRunner.java:177) 
    at org.junit.runners.BlockJUnit4ClassRunner.collectInitializationErrors(BlockJUnit4ClassRunner.java:122) 
    at org.junit.runners.ParentRunner.validate(ParentRunner.java:269) 
    at org.junit.runners.ParentRunner.<init>(ParentRunner.java:66) 
    at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:58) 
    at org.junit.internal.builders.JUnit4Builder.runnerForClass(JUnit4Builder.java:13) 
    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.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:452) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) 
    at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:62) 
    at org.eclipse.pde.internal.junit.runtime.PlatformUITestHarness$1.run(PlatformUITestHarness.java:47) 
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) 
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135) 
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140) 
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757) 
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701) 
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665) 
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499) 
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679) 
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) 
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668) 
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) 
    at com.ibm.stp.Application.start(Application.java:70) 
    at org.eclipse.pde.internal.junit.runtime.NonUIThreadTestApplication.runApp(NonUIThreadTestApplication.java:54) 
    at org.eclipse.pde.internal.junit.runtime.UITestApplication.runApp(UITestApplication.java:41) 
    at org.eclipse.pde.internal.junit.runtime.NonUIThreadTestApplication.start(NonUIThreadTestApplication.java:48) 
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) 
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) 
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) 
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344) 
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) 
    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 org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622) 
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577) 
    at org.eclipse.equinox.launcher.Main.run(Main.java:1410) 
    at org.eclipse.equinox.launcher.Main.main(Main.java:1386) 

回答

0

這是代碼本身也包含無論是在測試插件或插件片段(延伸的插件進行測試)?您不能只在普通Java項目中爲插件測試創建Java類。

+0

這是正常的測試類,但根據項目正常做法同塞。我們在2個源文件夾src下測試了一個插件項目。 src有實際的插件代碼,測試有Junit類的測試。這是一個簡單的POJO課程。一個測試方法與@Test註釋。 – Anandkumar

4

這是我的問題的解決方案。 我從工作區刪除項目。新創建從存儲庫檢出代碼。 junit-4.3.1.jar添加到類路徑中。 在依賴項選項卡中打開plugin.xml。在需要的插件下點擊添加按鈕 鍵入搜索org.junit。在我的eclipse(Indigo)org.junit(4.8.2.v4_8_2_v20110321-1705)中添加最新的一個,它顯示爲org.junit(4.8.2)。

修改的文件中: 的.classpath - 增加 「的junit-4.3.1.jar」 項 MANIFEST.MF - 要求束:,org.junit;捆綁版本= 「4.8.2」 得到了由於加在plugin.xml中更改。

感謝, 阿南德

+0

對我來說,只需將org.junit包添加到清單的依賴關係選項卡即可。感謝提示。 –