Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » using @Category annotation with SWTBot(is it possible to use @Category annotation in SWTBot tests)
using @Category annotation with SWTBot [message #1728712] Wed, 06 April 2016 15:29 Go to next message
Ess Kay is currently offline Ess KayFriend
Messages: 2
Registered: April 2016
Junior Member
The question may appear to be quite a naive one, but I just can't get my head round it.

Is it possible to use junit Categories in SWTBot tests? I have an example test suite (code below) while running it as 'SWTBot test', I get the following error:

Quote:
java.lang.Exception: Category annotations on Parameterized classes are not supported on individual methods.
at org.junit.runners.model.InitializationError.<init>(InitializationError.java:32)
at org.junit.experimental.categories.Categories.assertNoDescendantsHaveCategoryAnnotations(Categories.java:189)
at org.junit.experimental.categories.Categories.assertNoDescendantsHaveCategoryAnnotations(Categories.java:191)
at org.junit.experimental.categories.Categories.assertNoCategorizedDescendentsOfUncategorizeableParents(Categories.java:179)
at org.junit.experimental.categories.Categories.<init>(Categories.java:164)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:33)
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.swtbot.eclipse.core.RemotePluginTestRunner.main(RemotePluginTestRunner.java:64)
at org.eclipse.swtbot.eclipse.core.UITestApplication.runTests(UITestApplication.java:117)
at org.eclipse.e4.ui.internal.workbench.swt.E4Testable$1.run(E4Testable.java:73)
at java.lang.Thread.run(Thread.java:745)


The test suite I'm using:

SlowTestSuite.java
interface SlowTests {
}

@RunWith(Categories.class)
@IncludeCategory(SlowTests.class)
@SuiteClasses(A.class)
public class SlowTestSuite {
}


A.java
@RunWith(SWTBotJunit4ClassRunner.class)
public class A {
    
    private static SWTWorkbenchBot bot;
    
    @BeforeClass
    public static void firstBefore() {
        System.out.println("Executing A.firstBefore()");
        bot = new SWTWorkbenchBot();
    }
    
    @Test
    @Category(SlowTests.class)
    public void a() {
        System.out.println("Executing A.a()");
        System.out.println(bot.activeShell().getText());
        Assert.fail();
    }

    @Test
    public void b() {
        System.out.println("Executing A.b()");
    }

    @Test
    public void c() {
        System.out.println("Executing A.c()");
    }
    @AfterClass
    public static void after() {
        System.out.println("Executing A.after()");
    }
}


I tried using @Category annotation on the class level instead of individual method, but no luck. Any help will be much appreciated.
Re: using @Category annotation with SWTBot [message #1728991 is a reply to message #1728712] Sat, 09 April 2016 02:51 Go to previous messageGo to next message
Patrick Tasse is currently offline Patrick TasseFriend
Messages: 84
Registered: July 2009
Member
After googling a bit I got referred to this JUnit issue fixed in JUnit 4.13. What version are you using?

https://github.com/junit-team/junit4/issues/751

This was the duplicate issue that linked to it:

https://github.com/junit-team/junit4/issues/761

Let us know if that helps.
Re: using @Category annotation with SWTBot [message #1729129 is a reply to message #1728991] Mon, 11 April 2016 11:35 Go to previous message
Ess Kay is currently offline Ess KayFriend
Messages: 2
Registered: April 2016
Junior Member
Ahh, Thanks for your reply Patrick. I had googled quite a lot about it but it appears I somehow missed this link.

I'm using 4.12 that I suppose is the latest stable build. I'll however try and update to 4.13 to see if that works.

Regards.
Previous Topic:How to Set or type text in TextField of Table..?
Next Topic:Nebula NatTable is now supported
Goto Forum:
  


Current Time: Tue Mar 19 04:53:05 GMT 2024

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

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

Back to the top