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, I hope my point is clear and maybe shared!
Since @Category
isn't part of JUnit5 - Jupiter, I'm assuming you're using JUnit4. You can use @suiteClasses
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.