Open kvizcarra opened 7 years ago
This is similar to the issue raised in #29. As a workaround, you can stub instances of objects independently using ApexMocksConfig.HasIndependentMocks.
See #42 for examples of its usage.
Marked as an enhancement request.
Confirmed the workaround works
Inside a
testMethod
, we loop through a list ofTestCase
s, stub dependencies, and verify behavior. The problem we've encountered is theverify
call will fail on the second test case instance saying that the method was expected to be called once but actually was called twice. InstantiatingApexMocks
and the mock dependencies inside the loop doesn't work. What does work is if we pass unique inputs to the mock method we are verifying for each test case instance.Example
These test cases would fail:
And these would succeed:
Possible cause
After some digging into the library, I may have found what's causing this. It looks like the library is using
fflib_MethodCountRecorder.methodArgumentsByTypeName
to keep track of the method calls, but since it'sstatic
it persists for the entiretestMethod
process.