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

Viewed 83

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.

2 Answers

There are probably many ways to solve that from a technical point of view. For example, if you are using Maven, you could define a custom profile so that when enabled, it excludes these tests.

However, and without having enough context about why this is needed, this seems like a bad thing to do. Ideally you want tests to be runnable in the same way on both the developer machine and the CI. Having tests only run locally is problematic because it lacks all the benefits of the CI.

Related