question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pitest fails to run Junit5/Kotest tests because it assigns unique id selectors

See original GitHub issue

Which version of Kotest are you using I’m upgrading kotest from 5.1.0 (where it works fine) to 5.2.2 (where I have the error described below).

Description

In #2862, kotest was updated to throw an exception if tests running with kotest engine have a unique id selector.

Unfortunately, this is exactly what Pitest is doing:

PIT >> INFO : MINION : org.pitest.util.PitError: TestEngine with ID 'kotest' failed to discover tests
PIT >> FINE : MINION :      at org.pitest.util.Unchecked.translateCheckedException(Unchecked.java:20)
PIT >> FINE : MINION :      at org.pitest.coverage.execute.CoverageWorker.run(CoverageWorker.java:51)
PIT >> FINE : MINION :      at org.pitest.coverage.execute.CoverageMinion.main(CoverageMinion.java:88)
PIT >> FINE : MINION : Caused by: org.junit.platform.commons.JUnitException: TestEngine with ID 'kotest' failed to discover tests
PIT >> FINE : MINION :      at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverEngineRoot(EngineDiscoveryOrchestrator.java:160)
PIT >> FINE : MINION :      at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverSafely(EngineDiscoveryOrchestrator.java:134)
PIT >> FINE : MINION :      at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discover(EngineDiscoveryOrchestrator.java:108)
PIT >> FINE : MINION :      at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discover(EngineDiscoveryOrchestrator.java:80)
PIT >> FINE : MINION :      at org.junit.platform.launcher.core.DefaultLauncher.discover(DefaultLauncher.java:110)
PIT >> FINE : MINION :      at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
PIT >> FINE : MINION :      at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
PIT >> FINE : MINION :      at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
PIT >> FINE : MINION :      at org.pitest.junit5.JUnit5TestUnit.execute(JUnit5TestUnit.java:88)
PIT >> FINE : MINION :      at org.pitest.coverage.execute.CoverageDecorator.execute(CoverageDecorator.java:49)
PIT >> FINE : MINION :      at org.pitest.testapi.execute.containers.UnContainer.execute(UnContainer.java:31)
PIT >> INFO : MINION :      at org.pitest.util.Unchecked.translateCheckedException(Unchecked.java:20)
PIT >> FINE : MINION :      at org.pitest.testapi.execute.Pitest.executeTests(Pitest.java:57)
PIT >> INFO : MINION :      at org.pitest.coverage.execute.CoverageWorker.run(CoverageWorker.java:51)
PIT >> FINE : MINION :      at org.pitest.testapi.execute.Pitest.run(Pitest.java:48)
PIT >> FINE : MINION :      at org.pitest.coverage.execute.CoverageWorker.run(CoverageWorker.java:49)
PIT >> INFO : MINION :      at org.pitest.coverage.execute.CoverageMinion.main(CoverageMinion.java:88)
PIT >> FINE : MINION :      ... 1 more
PIT >> FINE : MINION : Caused by: java.lang.RuntimeException: Kotest does not allow running tests via uniqueId
PIT >> INFO : MINION :      at io.kotest.runner.junit.platform.KotestJunitPlatformTestEngine.discover(KotestJunitPlatformTestEngine.kt:119)

As you can see, org.pitest.junit5.JUnit5TestUnit is actually assigning unique id selectors.

Is there a way kotest can avoid this breaking behavior, at least when is run by Pitest? Thanks in advance!

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:11 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
ffeltrinellicommented, Apr 30, 2022

I guess you are referring to this one: https://kotest.io/docs/extensions/pitest.html . Thanks, I wasn’t aware of it!

Looking at its docs, I’m having some difficulties to understand how to set it up with Maven.

As regards all the Pitest configurations, should I keep using the Maven Pitest plugin (but without pitest-junit5-plugin), like this:

<plugin>
    <groupId>org.pitest</groupId>
    <artifactId>pitest-maven</artifactId>
    <version>1.7.6</version>
    <configuration>
        <targetClasses>...</targetClasses>
        <avoidCallsTo>...</avoidCallsTo>
        <coverageThreshold>...</coverageThreshold>
        ...        
    </configuration>
</plugin>

and then just adding the Pitest Kotest extension as dependency, like this:

<dependencies>
  ... the other dependencies on Kotest ... 
  <dependency>
    <groupId>io.kotest.extensions</groupId>
    <artifactId>kotest-extensions-pitest</artifactId>
    <version>1.1.0</version>
    <scope>test</scope>
  </dependency>
</dependencies>

?

0reactions
stale[bot]commented, Jun 4, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

FAQ
FAQ. What does PIT stand for? PIT began life as a spike to run JUnit tests in parallel, using separate classloaders to isolate...
Read more >
Mutation testing requires a green suite, but the ...
I have the following test cases that is fine when running under junit test but when running with pitest it fails.
Read more >
java - Pitest can't detect class of test
I need to add the junit5 plugin as a dependency (as I'm using JUnit 5). <plugin> <groupId>org.pitest</groupId> ...
Read more >
Real world mutation testing
That's it, you're up and running. By default pitest will mutate all code in your project. You can limit which code is mutated...
Read more >
Mutation Testing: Too Good to Be True?
Analysing Pitest, a JVM tool for mutation testing: how it works, ... If nothing fails, a test is missing or an existing test...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found