Junit4: launch a set of specific testing methods

Is there a way to create a set of test methods, not just test classes?

I would like to build a test suite that simply runs certain test methods from a test class. I see no way to do this from my limited knowledge of the unit and search on the Internet.

+5
source share
1 answer

Use the Categories function in JUnit4.

Example: if it is assumed that some methods will be executed, scattered both in ATestand BTest:

//Define Categories
@RunWith(Categories.class)  
@IncludeCategory(NeedTest.class)  
@SuiteClasses({ ATest.class,  BTest.class })  
class MySuite{
...
}

Then in ATestand BTestannotate your wait methods as:

@Test
@Category(NeedTest.class)  
public void test()

MySuite , @Category(NeedTest.class). , ,

ps: NeedTest.class - , .

+7

All Articles