import static org.easymock.EasyMock.*; import java.util.ArrayList; import java.util.List; import org.junit.rules.ExternalResource; /** * Mock resource class for cleanup mock objects after each test run. */ public class MockResource extends ExternalResource { private List Come to think of it, there will be sure more mocking work which can be done by a JUnit rule. So I think the rule feature is very nice and makes JUnit tests better to read ...
Mittwoch, 30. September 2009
JUnit 4.7 Rule for cleanup EasyMock object after test
I try the JUnit 4.7 rule feature and I wrote a super small ExternalResource class for easymock cleanup (reset) here is the example code that makes mocking setup easier: