Thanks for the quick reply. I did add the Runtime library com.instantiations.eclipse.util into my Dependencies. I tried the test several times and found the exception does not appear everytime.
Let me ask the question again. I did the following steps to create a test:
1. Follow the "Generate a Sample RCP Test " in the Guide to create a project and a test "AddContactTest"
2. Use JUnit 3 to playback the test and it works properly.
3. Add junit-4.3.1.jar into my build path
4. Change the AddContactTest and add @Test annotations. Please see the following source code:
- Code: Select all
import com.windowtester.runtime.swt.locator.MenuItemLocator;
import junit.extensions.UITestCaseSWT;
import com.windowtester.runtime.IUIContext;
import com.windowtester.runtime.swt.condition.shell.ShellShowingCondition;
import com.windowtester.runtime.swt.locator.LabeledTextLocator;
import com.windowtester.runtime.swt.locator.ButtonLocator;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.*;
public class AddContactTest extends UITestCaseSWT {
/**
* Main test method.
*/
@Test
public void testAddContact() throws Exception {
IUIContext ui = getUI();
ui.click(new MenuItemLocator("File/New Contact..."));
ui.wait(new ShellShowingCondition(""));
ui.enterText("asdf");
ui.click(new LabeledTextLocator("Last Name"));
ui.enterText("asdf");
ui.click(new LabeledTextLocator("Street"));
ui.enterText("asd");
ui.enterText("f");
ui.click(new LabeledTextLocator("City"));
ui.click(new ButtonLocator("&Finish"));
}
}
5. Change the test runner to Junit 4
6. Run the test again. Then I got the following error
java.lang.Exception: No runnable methods
at org.junit.internal.runners.TestClassMethodsRunner.testAborted(TestClassMethodsRunner.java:42)
at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:33)
at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:58)
at org.eclipse.pde.internal.junit.runtime.UITestApplication$1.run(UITestApplication.java:105)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:123)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3325)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2971)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1930)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1894)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:422)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at rcpContactMngr.Application.run(Application.java:18)
at org.eclipse.pde.internal.junit.runtime.UITestApplication.run(UITestApplication.java:45)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336)
at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
at org.eclipse.core.launcher.Main.run(Main.java:977)
at org.eclipse.core.launcher.Main.main(Main.java:952)
And sometims the "Exception in thread "CodePro UI Background Startup" java.lang.NoClassDefFoundError: org/eclipse/ui/PlatformUI" appears in the console as well.
Could you give me any hint for this?