JUnit 5 / Intellij / custom test engine / method selection issue

197 views Asked by At

I have written a custom JUnit 5 test engine for parameterized testing at the test class level. I have found an issue I can seem to resolve.

When using IntelliJ and running the test class, everything works...

IntelliJ test window when running test class

When I run a specific parameter, everything works...

IntelliJ test window when running test parameter

When I run a specific method for a specific parameter, all test methods run...

IntelliJ test window when running test method

Every node in the hierarchy has a UniqueId, so I would expect IntelliJ to use a UniqueIdSelector, but debugging shows that it's using a MethodSelector

Engine Discovery Request

If the method had parameters, then I could use the methodParameterType field to filter... but in this scenario, there are no test method parameters.

Thoughts? Anyone experience this issue? Is it a core IntelliJ issue/limitation or JUnit 5 issue/limitation?

1

There are 1 answers

1
JojOatXGME On

I also encountered the same problem. By taking a look into the source code of IntelliJ, I discovered two solutions to make IntelliJ use the UniqueIdSelector.

  1. Use a MethodSource or ClassSource which points to a method or class which is not annotated with @Testable.
  2. Use the same source as you have used for the parent node. For example, you could make every test use the test class as the source, instead of the individual methods.

Both solutions have downsides, of course. Removing the @Testable annotation means you can no-longer trigger the test from the source file in IntelliJ. Using the class as the test source for all nodes means you can no-longer jump to the method in the source code.

PS: I assume you have created IDEA-317561? I also created IDEA-337243. Just for reference.