Class | Description |
---|---|
JUnit5Mockery |
A
JUnit5Mockery is a JUnit Extension that manages JMock
expectations and allowances, and asserts that expectations have been met
after each test has finished. |
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(); } }
Copyright © 2003–2024 jMock. All rights reserved.