I noticed some unit tests, like in the spring framework where you setup the object and the test but don’t explicitly use the assert methods.
Essentially, you have an exception or not.
Is this unit testing? Is this something to avoid? For example, here are some tests from the Spring framework. No assert clauses, just a test.
public void testNeedsJoinPoint() { mockCollaborator.needsJoinPoint('getAge'); mockControl.replay(); testBeanProxy.getAge(); mockControl.verify(); }
The test you are showing is full of expectations, but they are expressed in terms of the mock object.
Some tests may be totally void of asserts and still be ok with me, for instance a test that simply loads the spring context and (implicitly) asserts its validity. I really think the question should be if it is a good test. Sometimes it may be, and sometimes it’s just the best you can get. And it may often be a lot better than nothing.