We use jMock for a lot of our Java tests. In some test classes, most of the tests work the same way, so common expectations end up in a setUp()
method.
Quite often, some of the expectations in the setUp()
method are only used for some of the tests. So all these expectations tend to be allowing()
types which don't require being called every test.
Now, sometimes code internal to the system changes in a way which removes an expectation. For instance, maybe a deprecated API call gets replaced with a non-deprecated one. But these expectations continue to succeed because they don't require at least one call. As far as I know, there is no way to say "require at least one call across this entire test class", and it's a different instance of Mockery
every time anyway, so that would never work.
Nonetheless, it would be nice if I had a way to track these down and automatically delete them.
I figure I could do it manually... Delete a line at random -> See if the tests still pass -> If they pass, commit, otherwise revert -> Repeat.
But is there an automatic way? (Other than obviously writing my own tool to automate the manual process.)