1

We have an internal tool that distributes hundreds of thousands of tests to cloud workers. I've written a tool that discovers all the tests that need to be run using a LauncherDiscoverRequest, and everything is working. However, some of our tests (and test classes) are annotated with @Disabled or @Ignore. These tests are still discovered and assigned to test workers, but of course the tests don't do anything, so they're just wasting resources. I'd like to identify and filter these tests at discovery time, so that they aren't included in the TestPlan.

I found JupiterTestDescriptor::shouldBeSkipped(JupiterEngineExecutionContext), but I don't see a good way to invoke that from, e.g., a PostDiscoveryFilter.

I can use a custom PostDiscoveryFilter to identify each test's source, and then use reflection to determine if the method or class is annotated, but that's hacky and doesn't cover the general case: there are other ways to disable tests.

What's the best way to filter out skipped tests at discovery time?

pburka
  • 1,434
  • 9
  • 12

1 Answers1

1

You cannot filter out disabled tests since disabled tests are reported as such. What you could do is to introduce your own annotation, eg @MyDisabled which has meta annotations @Disabled and @Tag(“mytag“). Thus the tests are disabled and you can filter out the tag.

johanneslink
  • 4,877
  • 1
  • 20
  • 37