The JUnit FAQ has a section on testing methods that return void
. In your case, you want to test a side effect of the method called.
The example given in the FAQ tests that the size of a Collection
changes after an item is added.
@Test
public void testCollectionAdd() {
Collection collection = new ArrayList();
assertEquals(0, collection.size());
collection.add("itemA");
assertEquals(1, collection.size());
collection.add("itemB");
assertEquals(2, collection.size());
}