Skip to content

Conversation

@MartinWheelerMT
Copy link
Collaborator

@MartinWheelerMT MartinWheelerMT commented Oct 7, 2025

What

  • Move SendContinueHandlerFailure test to its own class.
  • Move now shared methods into base class.
  • Add TestConfiguration to new test class to ensure that the mock is fully created before wiring.

Why

To address a thread-safety issue in the way Mockito handles mocks:

Is Mockito thread-safe?

For healthy scenarios Mockito plays nicely with threads. For instance, you can run tests in parallel to speed up the build. Also, you can let multiple threads call methods on a shared mock to test in concurrent conditions.

However Mockito is only thread-safe in healthy tests, that is tests without multiple threads stubbing/verifying a shared mock. Stubbing or verification of a shared mock from different threads is NOT the proper way of testing because it will always lead to intermittent behavior. In general, mutable state + assertions in multi-threaded environment lead to random results. If you do stub/verify a shared mock across threads you will face occasional exceptions like: WrongTypeOfReturnValue, etc.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have performed a self-review of my code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the Changelog with details of my change in the UNRELEASED section if this change will affect end users
  • A corresponding change has been made to the Mapping Documentation repository

* Move SendContinueHandlerFailure test to its own class.
* Move now shared methods into base class.
* Add `TestConfiguration` to new test class to ensure that the mock is fully created before wiring.
@MartinWheelerMT MartinWheelerMT requested a review from a team as a code owner October 7, 2025 16:54
@github-actions
Copy link

github-actions bot commented Oct 8, 2025

Looks good. No mutations were possible for these changes.
See https://pitest.org

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant