I am organizing some tests into suites, which is great, but I need to ignore the tests that are part of a suite so that my build doesn't run them automatically.
I can achieve that by excluding them from the build process, but wanted to see if JUnit supports that natively.
What is the cleanest way to achieve that?
EDIT: In order to achieve that in a maven build I can categorize the tests (https://stackoverflow.com/a/14133020/819606) and exclude an entire category (https://stackoverflow.com/a/18678108/819606).
Junit4 - You can try using
transformed to something like -
Source - Ignore in Junit4
Junit5 - You can try something similar like -
Source - Disabling Tests in Junit5
along with suite implementation in Junit5 as
where
@SelectPackages
specifies the names of packages to select when running a test suite via@RunWith(JUnitPlatform.class)
, so you can specify those which you want to execute OR those which you don't want to execute and mark them disabled as above.Further reads - @Select in Junit5 and Running a Test Suite in Junit5