Daily tip #13
Tip of the day #13
If you are using JUnit5, try to add @Tag annotation in your tests. You can configure your pipeline to use it, and skip or run your custom tags. Start with @Tag(“IntegrationTests”) and happy testing!
History
JUnit 5 introduced the concept of tags, which are essentially labels that you can add to your tests. You can then use these tags to filter which tests to run or ignore.
@Tag("IntegrationTests")
class MyIntegrationTests {
@Test
void test1() {
// ...
}
@Test
void test2() {
// ...
}
}
You can then run only the tests with a given tag by using the --include-tag
option:
$ mvn test -Dgroups="IntegrationTests"
Similarly, we can exclude tests with a given tag by using the --exclude-tag
option:
$ mvn test -Dgroups="UnitTests" -DexcludedGroups="IntegrationTests"
Or you can use JUnit and create a test suit.
How to
Take a look in repo-tip-13 to see a real example of today’s tip.