Debian Codegraph @

jmock-junit5/src/main/java/org/jmock/junit5/package.html

raw
1 <html>
2 <body>
3 <p>Integrates jMock with <a href="https://junit.org/junit5/">JUnit 5</a>.</p>
4 <p>To write a mock object test in JUnit 5, declare a non-private field of type JUnit5Mockery
5 that holds a JUnit5Mockery and annotate the field with
6 <code>@RegisterExtension</code>, as shown below. The Mockery will
7 be verified after the test has run and before the fixture is torn down.
8 </p>
9
10 <pre>
11 public class JUnit5TestThatDoesSatisfyExpectations {
12
13 \@RegisterExtension
14 JUnit5Mockery context = new JUnit5Mockery();
15
16 \@Mock
17 private Runnable runnable;
18
19 \@Test
20 public void doesSatisfyExpectations() {
21 context.checking(new Expectations() {{
22 oneOf (runnable).run();
23 }});
24
25 runnable.run();
26 }
27 }
28 </pre>
29
30 </body>
31 </html>