|
|||||||||
| PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES | ||||||||
See:
Description
| Class Summary | |
|---|---|
| JMock | A test Runner that asserts that all expectations have been met after
the test has finished and before the fixture is torn down. |
| JUnit4Mockery | A Mockery that reports expectation errors as JUnit 4 test failures. |
Integrates jMock with JUnit 4.
To write a mock object test in JUnit 4, declare a field of type Mockery
that holds a JUnit4Mockery and annotate your test class with
@RunWith(JMock.class), as shown below. The Mockery will
be verified after the test has run and before the fixture is torn down.
import org.jmock.Expectations; import org.jmock.Mockery; import org.jmock.integration.junit4.JMock; import org.jmock.integration.junit4.JUnit4Mockery; import org.junit.Test; import org.junit.runner.RunWith; ... @RunWith(JMock.class) public class ExampleJUnit4MockObjectTest { Mockery context = new JUnit4Mockery(); ... @Test public void dispatchesEventToSessionsOtherThanThenSender() { ... context.checking(new Expectations() {{ ... }}); ... } }
|
|||||||||
| PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES | ||||||||