You need to sign in to do that
Don't have an account?
Is there a way to assert the number of times a method is invoked?
Hello all,
I was wondering if there was any way inside of a test method, to assert the number of times a method is invoked or in this specific case, the number of times an object was updated.
I have a trigger which is responsible for updating an sObject, but only under certain conditions.
Besides asserting that the field has not been initialized, is there some way of ensuring that the sobject was not updated during the test / determining how many times the update method was called on the object?
If not, this would be a very nice feature for the apex language to have.
Thank you,
-Zach
As far as within native functionality, there isn't. But, you could wire up that class to have a static member that counts it's usage, which you can then examine. Like this:
All Answers
As far as within native functionality, there isn't. But, you could wire up that class to have a static member that counts it's usage, which you can then examine. Like this:
Thanks fox,
I thought about doing something like this but I'm not sure whether or not the rest of my team would approve.
Hopefully SF will at some point focus on improving the features of unit tests in Apex.