You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Inside a testMethod, we loop through a list of TestCases, stub dependencies, and verify behavior. The problem we've encountered is the verify call will fail on the second test case instance saying that the method was expected to be called once but actually was called twice. Instantiating ApexMocks 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.
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's static it persists for the entire testMethod process.
The text was updated successfully, but these errors were encountered:
This is similar to the issue raised in #29. As a workaround, you can stub instances of objects independently using ApexMocksConfig.HasIndependentMocks.
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.The text was updated successfully, but these errors were encountered: