Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Cfo2K4u4rF18QsPXPFnytf
17 lines
1.2 KiB
Plaintext
17 lines
1.2 KiB
Plaintext
PotentialStubbingProblem:
|
|
Strict stubbing argument mismatch. Please check:
|
|
- this invocation of 'charge' method:
|
|
paymentGateway.charge("acc-1", 1000L);
|
|
-> at lab.mockito.CheckoutService.checkout(CheckoutService.java:20)
|
|
- has following stubbing(s) with different arguments:
|
|
1. paymentGateway.charge("acc-1", 900L); stubbed with: [Returns: Receipt[id=r, account=acc-1, cents=900, approved=true]]
|
|
-> at lab.mockito.StrictnessTest.sameMethodDifferentArgumentsIsAPotentialStubbingProblem(StrictnessTest.java:48)
|
|
Typically, stubbing argument mismatch indicates user mistake when writing tests.
|
|
Mockito fails early so that you can debug potential problem easily.
|
|
However, there are legit scenarios when this exception generates false negative signal:
|
|
- stubbing the same method multiple times using 'given().will()' or 'when().then()' API
|
|
Please use 'will().given()' or 'doReturn().when()' API for stubbing.
|
|
- stubbed method is intentionally invoked with different arguments by code under test
|
|
Please use default or 'silent' JUnit Rule (equivalent of Strictness.LENIENT).
|
|
For more information see javadoc for PotentialStubbingProblem class.
|