Skip to content

RequireParallelTesting Annotation not working #1261

@thamp59

Description

@thamp59

Prerequisites

Please answer the following questions for yourself before submitting an issue.

  • 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 @RequireParallelTesting annotation in test classes for test task I would expect test results to be the same as test classes not running in parallel.

Current Behavior

For tests using the @RequireParallelTesting annotation, the error received is io.mockk.MockKException: no answer found for <some mock> among the configured answers

Failure Information (for bugs)

Please help provide information about the failure if this is a bug. If it is not a bug, please remove the rest of this template.

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. Use @RequireParallelTesting with Test Classes
  2. Debug through to clearAllMocks() and observe that it is still being hit

Context

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

My team was waiting on #1133 to be completed as that seemed to be the issue related to our desire to run our tests in parallel. Upon checking that #1133 was completed and deployed, we updated our version to latest and noticed the annotation still was not working.

  • MockK version: 1.13.11
  • OS: Windows 11
  • Kotlin version: 1.9.24
  • JDK version: 21
  • JUnit version: 4.13.2
  • Type of test: Unit Test

Possible Solution

The annotation is not being used
image

If the annotation takes priority over the system property (this looks to be consistent with other flags in the repo) the ExtensionContext.requireParallelTesting should become:

  private val ExtensionContext.requireParallelTesting: Boolean
    get() = testClass.requireParallelTesting ||
      getConfigurationParameter(REQUIRE_PARALLEL_TESTING).map { it.toBoolean() }.orElse(false)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions