Reputation: 1070
I'd like to know if there is any way to gather a set of test classes together and to run one category of tests that is common for for those tests. I'll try to explain on an example:
I have those 2 Categories:
public interface Slowtests{}
public interface Fasttests{}
And the following classes and methods:
@Category({SLowTests.class, FastTests.class})
Class A extends TstBase {
@Category({SLowTests.class})
void a1() {}
@Category({FastTests.class})
void a2() {}
@Category({SLowTests.class, FastTests.class})
void a3() {}
}
@Category({SLowTests.class, FastTests.class})
Class B extends TstBase {
@Category({SLowTests.class})
void b1() {}
void b2() {}
}
@Category({SLowTests.class, FastTests.class})
Class C extends TstBase{
void c1() {}
void c2() {}
}
Now let's say I'd like to run all Fast Tests classes from A
and B
and C
under same Test Suite and to run only the tests annotationed with FastTests
category.
Hope my question is clear enough. Please advise what can I do?
Upvotes: 0
Views: 556
Reputation: 15709
Define your test suite like this:
@RunWith(Categories.class)
@Categories.IncludeCategory(FastTests.class)
@Suite.SuiteClasses( /* Your test classes here */)
public class FastTestSuite {
}
Here's the official documentation and example.
Upvotes: 1