• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hazendaz / jmockit1 / 470

08 Nov 2025 06:19PM UTC coverage: 72.202% (-0.07%) from 72.268%
470

push

github

web-flow
Merge pull request #409 from hazendaz/junit6

[pom] Bump junit to 6.0.1

5676 of 8360 branches covered (67.89%)

Branch coverage included in aggregate %.

11924 of 16016 relevant lines covered (74.45%)

0.74 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

41.86
/main/src/main/java/mockit/integration/junit4/FakeRunNotifier.java
1
/*
2
 * Copyright (c) 2006 JMockit developers
3
 * This file is subject to the terms of the MIT license (see LICENSE.txt).
4
 */
5
package mockit.integration.junit4;
6

7
import edu.umd.cs.findbugs.annotations.NonNull;
8

9
import mockit.Invocation;
10
import mockit.Mock;
11
import mockit.MockUp;
12
import mockit.coverage.testRedundancy.JUnitListener;
13
import mockit.coverage.testRedundancy.TestCoverage;
14
import mockit.integration.TestRunnerDecorator;
15
import mockit.internal.faking.FakeInvocation;
16
import mockit.internal.state.TestRun;
17

18
import org.junit.runner.Description;
19
import org.junit.runner.Result;
20
import org.junit.runner.notification.RunNotifier;
21

22
/**
23
 * Startup fake which works in conjunction with {@link JUnit4TestRunnerDecorator} to provide JUnit 4.5+ integration.
24
 * <p>
25
 * This class is not supposed to be accessed from user code. JMockit will automatically load it at startup.
26
 */
27
public final class FakeRunNotifier extends MockUp<RunNotifier> {
1✔
28
    @Mock
29
    public static void fireTestRunStarted(Invocation invocation, Description description) {
30
        RunNotifier it = invocation.getInvokedInstance();
×
31
        assert it != null;
×
32

33
        TestCoverage testCoverage = TestCoverage.INSTANCE;
×
34

35
        if (testCoverage != null) {
×
36
            it.addListener(new JUnitListener(testCoverage));
×
37
        }
38

39
        prepareToProceed(invocation);
×
40
        it.fireTestRunStarted(description);
×
41
    }
×
42

43
    private static void prepareToProceed(@NonNull Invocation invocation) {
44
        ((FakeInvocation) invocation).prepareToProceedFromNonRecursiveMock();
1✔
45
    }
1✔
46

47
    @Mock
48
    public static void fireTestStarted(Invocation invocation, Description description) {
49
        Class<?> currentTestClass = TestRun.getCurrentTestClass();
1✔
50

51
        if (currentTestClass != null) {
1✔
52
            Class<?> newTestClass = description.getTestClass();
1✔
53

54
            if (newTestClass == null || !currentTestClass.isAssignableFrom(newTestClass)) {
1!
55
                TestRunnerDecorator.cleanUpMocksFromPreviousTestClass();
1✔
56
            }
57
        }
58

59
        prepareToProceed(invocation);
1✔
60

61
        RunNotifier it = invocation.getInvokedInstance();
1✔
62
        assert it != null;
1!
63
        it.fireTestStarted(description);
1✔
64
    }
1✔
65

66
    @Mock
67
    public static void fireTestRunFinished(Invocation invocation, Result result) {
68
        TestRun.enterNoMockingZone();
×
69

70
        try {
71
            TestRunnerDecorator.cleanUpAllMocks();
×
72

73
            prepareToProceed(invocation);
×
74

75
            RunNotifier it = invocation.getInvokedInstance();
×
76
            assert it != null;
×
77
            it.fireTestRunFinished(result);
×
78
        } finally {
79
            TestRun.exitNoMockingZone();
×
80
        }
81
    }
×
82
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc