Package org.jmock.junit5
Integrates jMock with JUnit 5.
To write a mock object test in JUnit 5, declare a non-private field of type JUnit5Mockery
that holds a JUnit5Mockery and annotate the field with
@RegisterExtension
, as shown below. The Mockery will
be verified after the test has run and before the fixture is torn down.
public class JUnit5TestThatDoesSatisfyExpectations { \@RegisterExtension JUnit5Mockery context = new JUnit5Mockery(); \@Mock private Runnable runnable; \@Test public void doesSatisfyExpectations() { context.checking(new Expectations() {{ oneOf (runnable).run(); }}); runnable.run(); } }
-
Class Summary Class Description JUnit5Mockery AJUnit5Mockery
is a JUnit Extension that manages JMock expectations and allowances, and asserts that expectations have been met after each test has finished.