Skip to content

Mockk lost support for parallel test execution in version 1.13.7 #1133

@bay73

Description

@bay73

It seems the version 1.13.7 has lost support for parallel execution. I would blame this change: #1099.
clearAllMocks is known to not be thread safe and now it is called after each test. In previous version the issue with clearAllMocks could have been avoided by putting tests which use this function out of parallel execution scope. Now the issue affects all tests and parallel execution seems completely impossible.

  • I am running the latest version
  • I checked the documentation and found no answer
  • I checked to make sure that this issue has not already been filed

Expected Behavior

When using systemProperty("junit.jupiter.execution.parallel.enabled", "true") in gradle setting for test task I would expect test results to be the same as for disabled parallel execution.

Current Behavior

Many tests fail with
io.mockk.MockKException: no answer found for <some mock> among the configured answers

Steps to Reproduce

Put systemProperty("junit.jupiter.execution.parallel.enabled", "true") into your build.gradle.kts file

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

  • MockK version: 1.13.7
  • Kotlin version: 1.9.0
  • JUnit version: 5.6.2
  • Type of test: unit test

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions