Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests get run multiple times when test contains when clause with enums AND using maxParallelForks #3973

Open
mightyguava opened this issue Apr 17, 2024 · 0 comments
Labels
bug 🐛 Issues that report a problem or error in the code. framework 🏗️ Pertains to the core structure and components of the Kotest framework.

Comments

@mightyguava
Copy link

mightyguava commented Apr 17, 2024

Kotest version: 5.8.1

This is one of the weirder bugs I've seen.

Repro here, containing a single commit on top of the kotest-examples-multiplatform repo main.

If you run ./gradlew cleanJvmTest jvmTest, you'll see that every test within the module is run twice. This is also visible from build/reports/tests/jvmTest/index.html. If maxParallelForks is set to 1, this issue does not occur.

If you copy the test case in WhenTest, each new copy of the test case will cause all tests to be run an additional time.

Based on trial and error, I narrowed this down to when clauses being added to the test that operate on an enum. Looking at the compiled classes, I suspect it has something to do with this $WhenMappings class that is generated, e.g.

build/classes/kotlin/jvm/test/io/kotest/examples/mpp/whendupe/BarTests$1$1$WhenMappings.class

Each test case that uses a when on an enum seems to generate a extra inner class... and my hypothesis is that Kotest's runner (or JUnit framework? or Gradle?) isn't deduping this with the outer class properly.

@Kantis Kantis added bug 🐛 Issues that report a problem or error in the code. framework 🏗️ Pertains to the core structure and components of the Kotest framework. labels Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Issues that report a problem or error in the code. framework 🏗️ Pertains to the core structure and components of the Kotest framework.
Projects
None yet
Development

No branches or pull requests

2 participants