pitest-junit5-plugin icon indicating copy to clipboard operation
pitest-junit5-plugin copied to clipboard

Fix JUnit5 test execution after discovery

Open tvcsantos opened this issue 4 years ago • 2 comments

JUnitTestFinder is obtaining the correct tests from the project and assigning a correct uniqueid to each test. After this when this unit test is executed (JUnit5TestUnit#execute) the LauncherDiscoveryRequest is executed once again with a selector for the uniqueid in order do identity the test. This is ok, but not enough and gives wrong results specially when we have different test engines (junit5, kotest, ...) running. With this approach and after seeing the internal implementation when we are executing, a test plan is made including all engines and it is picking up everything for every engine including unrelated tests.

In order to solve this we have to prune this unrelated tests by applying a post filter. The effect of this is to remove all unrelated engines and tests from the Hierarchy within the test plan.

Also in this commit I've updated the version to follow the semver standard approach c.f. https://semver.org/

tvcsantos avatar Apr 10 '20 12:04 tvcsantos

~~It seems that this doesn't play well with nested and dynamic tests. I'll investigate on this. If someone can give me an hand I would appreciate~~

tvcsantos avatar Apr 10 '20 13:04 tvcsantos

Ok so the problem was dynamic testing. I've take that into account in the fix.

tvcsantos avatar Apr 10 '20 15:04 tvcsantos

With this approach and after seeing the internal implementation when we are executing, a test plan is made including all engines and it is picking up everything for every engine including unrelated tests.

Is this really the case? When using a discovery selector for the unique id, the test engines should only discover that exact test and nothing more, shouldn't they? Maybe it is more that some test engines misbehave in that regard? Or is this obsolete by now and working with latest versions?

Vampire avatar May 25 '23 12:05 Vampire

With this approach and after seeing the internal implementation when we are executing, a test plan is made including all engines and it is picking up everything for every engine including unrelated tests.

Is this really the case? When using a discovery selector for the unique id, the test engines should only discover that exact test and nothing more, shouldn't they? Maybe it is more that some test engines misbehave in that regard? Or is this obsolete by now and working with latest versions?

After some time I’ve stopped using this plugin and didn’t test on newer versions so let us consider this obsolete for now. I will close it, thanks for your reply.

tvcsantos avatar Jun 07 '23 19:06 tvcsantos