Any configurations required for running with JUnit4?

WindowTester allows you to easily create and run unit tests for every GUI they build. It can also be used to generate system level tests.

Moderators: gnebling, Eric Clayberg, Dan Rubel, keertip, Phil Quitslund

Any configurations required for running with JUnit4?

Postby jasonwang » Thu Jul 19, 2007 12:02 am

Get the following errors when running a test with JUnit4. Is there any setting required? Please advise. Thanks.

Exception in thread "CodePro Background Startup" java.lang.NoClassDefFoundError: com/instantiations/eclipse/util/ExtensionPointUtilities
at com.instantiations.eclipse.startup.StartupManager.getExtensions(StartupManager.java:261)
at com.instantiations.eclipse.startup.StartupManager.start0(StartupManager.java:108)
at com.instantiations.eclipse.startup.StartupManager.access$0(StartupManager.java:99)
at com.instantiations.eclipse.startup.StartupManager$1.run(StartupManager.java:87)
Exception in thread "CodePro UI Background Startup" java.lang.NoClassDefFoundError: org/eclipse/ui/PlatformUI
at com.instantiations.eclipse.startup.StartupListener.waitForWorkbench(StartupListener.java:82)
at com.instantiations.eclipse.startup.StartupListener.earlyStartupInBackground(StartupListener.java:56)
at com.instantiations.eclipse.startup.StartupListener.access$0(StartupListener.java:52)
at com.instantiations.eclipse.startup.StartupListener$1.run(StartupListener.java:41)
jasonwang
 
Posts: 11
Joined: Tue Jul 17, 2007 10:51 pm

Postby gnebling » Thu Jul 19, 2007 6:34 am

This is not specific to JUnit 4. You need to add the WindowTester Runtime library to your test project's build path. If your test project is a plug-in project, open your MANIFEST file and add com.instantiations.eclipse.util to your Dependencies tab.
gnebling
Moderator
 
Posts: 243
Joined: Tue Aug 22, 2006 7:49 am

Postby jasonwang » Thu Jul 19, 2007 5:28 pm

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?
jasonwang
 
Posts: 11
Joined: Tue Jul 17, 2007 10:51 pm

Postby gnebling » Thu Jul 19, 2007 8:47 pm

Thanks for providing more information. The "No runnable methods" error indicates your test did not have at least one @Test annotation. Are you sure you ran the test after you added @Test? Just making sure.

I ran your test and I got a different error message, "Display has not been initialized". If I comment out the @Test annotation, then I get the same error you're getting. Could you tell me exactly what environment you're using? OS, IDE version/distribution, Java version.
gnebling
Moderator
 
Posts: 243
Joined: Tue Aug 22, 2006 7:49 am

Postby jasonwang » Thu Jul 19, 2007 10:03 pm

Now I can get the message "Display has not been initialized" after the following changes:
1. Remove junit-4.3.1.jar from build path
2. Add org.junit4 into the project Dependencies

I think the only difference is that org.junit4 is junit-4.1.jar

My environment:
Eclipse SDK: Version: 3.2.2 Build id: M20070212-1330
OS: Windows 2000 Advanced Server
Java: jdk1.5.0 update 12
jasonwang
 
Posts: 11
Joined: Tue Jul 17, 2007 10:51 pm

Postby Phil Quitslund » Fri Jul 20, 2007 8:10 am

As you're discovering, JUnit4 is not really supported by the current WindowTester runtime. To support JUnit4 properly the functionality in UITestCaseSWT needs to be moved into a custom runner. (The rub is we need to override and manage runBare().) Anyway, this is a bit tricky because the runner story is not designed with extension/modification in mind (David Saff admitted as much to me in a conversation at a recent conference). It's possible that this is improved with Junit4.4. Either way, this is something we want to readdress.

How important is JUnit4 support for you? What are the JUnit4 features you need the most?

I suggest we follow this up with a a feature request sent to:

wintest-support@instantiations.com

Thanks!

-phil
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am

Postby jasonwang » Sun Jul 22, 2007 10:56 pm

Thank you for the reply.

How important is JUnit4 support for you? What are the JUnit4 features you need the most?


Not very much. JUnit 3 is ok as well.
jasonwang
 
Posts: 11
Joined: Tue Jul 17, 2007 10:51 pm

Postby Phil Quitslund » Mon Jul 23, 2007 8:18 am

Good to know. I'm actively re-investigating JUnit4 support so help may soon be on the way.

I'll post to this thread when there's a beta to test.

Thanks!

-phil
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am


Return to Window Tester

Who is online

Users browsing this forum: No registered users and 1 guest