lundi 16 décembre 2019

JUnit @Category method annotation to override class annotation

I have a bunch of integration test in many *IT.java classes. To start I want to have all the tests categorized as Integration test so I annotate the tests with

@Category(IntegrationTest.class)
public class FooClass

At the same time it would be great to categorize at method level those tests that we want to include in other categories:

@Test
@Category(RegressionTest.class)
public void fooMethod()

So that, and it makes a lot of sense, when I want to execute the integration test it will run all the tests. Also, with the same configuration, I would be able to run only the regression test if I explicitly run the RegressionTest Category.

But it seems that is the class level annotation which have prevalence over method level annotation. Then I only have two choices to accomplish my goal and they are not really smart.

So, my question is, there is any advanced configuration I could use in JUNIT to achieve the desired functionality?

Many thanks, hope I showed my point well

Aucun commentaire:

Enregistrer un commentaire