Search code examples
javamavenjunit

Is there some kind of "hidden @Ignore" for Java Tests


So we have some tests that only serve a purpose of running them locally. For example, we have a test that uses internal classes to download a file from the cloud.

This test should not be run in our CI, so we put it on @Ignore. There are two downsides with this approach though:

  1. The test is shown as "ignored" in the CI
  2. You have to remove the @Ignore before every run

So I wondered if there is any way to let CI ignore some tests completely, so I can only run them locally?

Just to clarify: This is not about conditionally ignoring tests - it is about hiding tests completely.


Solution

  • JUnit offers support for @Category (JUnit 4) or @Tag (JUnit 5) allowing you to annotate your individual tests or classes and then selecting the categories you want to run from maven (or you can exclude like in your case by using excludedGroups).