Skip to main content



      Home
Home » Eclipse Projects » SWTBot » @Test annotations ignored, how to get testcase to use Junit 4 ?
@Test annotations ignored, how to get testcase to use Junit 4 ? [message #33351] Thu, 23 April 2009 23:12 Go to next message
Eclipse UserFriend
I am extending SWTAbstractTestCase, and I specify org.junit4 (4.3.1) in
the dependencies section of the manifest associated with that plugin. But
it only executes the tests if I have "test" in the beginning of the method
name. I do specify Junit 4 as the test runner in Run Configurations. I
then monitor the testcase in the Junit view, (which says "Runner: Junit 4"
if I hover over the tab), but still it only executes the testcases that
say "test" in it (which I understand is a Junit 3 thing right?)... All my
testcases marked with the @Test annotation are ignored. And if I don't
have any methods with "test" in the beginning, then it displays the
following exception:

junit.framework.AssertionFailedError: No tests found in
com.ibm.datastudio.common.gui.framework.bvt.tests.bvtshsh_id a
at junit.framework.Assert.fail(Assert.java:47)
at junit.framework.TestSuite$1.runTest(TestSuite.java:97)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at
org.junit.internal.runners.OldTestClassRunner.run(OldTestCla ssRunner.java:76)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.r un(JUnit4TestReference.java:45)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(Test Execution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:460)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
at
org.eclipse.swtbot.eclipse.core.RemotePluginTestRunner.main( RemotePluginTestRunner.java:64)
at
org.eclipse.swtbot.eclipse.core.UITestApplication.runTests(U ITestApplication.java:123)
at
org.eclipse.ui.internal.testing.WorkbenchTestable$1.run(Work benchTestable.java:68)
at java.lang.Thread.run(Thread.java:735)

Any idea why it doesn't seem to be picking up Junit 4? Thanks a lot!
Re: @Test annotations ignored, how to get testcase to use Junit 4 ? [message #33517 is a reply to message #33351] Fri, 24 April 2009 03:23 Go to previous message
Eclipse UserFriend
I recommend you not to subclass any SWTBot super class for your JUnit
tests if you want to use JUnit 4.x. To my knowledge the JUnit superclasses
of SWTBot are only intended for JUnit 3.

I write SWTBot JUnit 4 tests this way:

@RunWith(SWTBotJunit4ClassRunner.class)
public class MyTest {
@Test
public void checkSomething() {
// ...
}

A suite can be written like this:

@RunWith(Suite.class)
@SuiteClasses({MyTest.class})
public class MySuite {
}

The annotation "@RunWith(SWTBotJunit4ClassRunner.class)" is needed for the
screenshot-on-failure/error feature of SWTBot.

I hope this helps.
Previous Topic:Can SWT-Bot test RCP-based applications?
Next Topic:ItemTable selected
Goto Forum:
  


Current Time: Thu Jun 12 18:40:37 EDT 2025

Powered by FUDForum. Page generated in 0.06140 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top