How to use fireTestRunStarted method of org.junit.runner.notification.RunNotifier class

Best junit code snippet using org.junit.runner.notification.RunNotifier.fireTestRunStarted

Run junit automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

copy
1package edu.tamu.aser.reex;
2import org.junit.runner.Description;
3import org.junit.runner.Result;
4import org.junit.runner.notification.Failure;
5import org.junit.runner.notification.RunListener;
6import org.junit.runner.notification.RunNotifier;
7import org.junit.runner.notification.StoppedByUserException;
8
9public class JUnit4WrappedRunNotifier extends RunNotifier {
10
11    private final RunNotifier notifier;
12
13    private boolean testExpStarted;
14
15    private Description runningTestDescription;
16
17    private Failure testFailure;
18
19    public JUnit4WrappedRunNotifier(RunNotifier notifier) {
20        this.notifier = notifier;
21    }
22
23    /**
24     * Test exploration is starting reset failed status
25     */
26    public void testExplorationStarted() {
27        this.testExpStarted = true;
28        this.testFailure = null;
29    }
30
31    /**
32     * Only fire started event if the exploration is starting
33     */
34    @Override
35    public void fireTestStarted(Description description) throws StoppedByUserException {
36        if (this.testExpStarted) {
37            this.notifier.fireTestStarted(description);
38            this.runningTestDescription = description;
39            // No longer starting
40            this.testExpStarted = false;
41        }
42    }
43
44    /**
45     * Intercept test failure
46     */
47    @Override
48    public void fireTestAssumptionFailed(Failure failure) {
49        this.notifier.fireTestAssumptionFailed(failure);
50        this.testFailure = failure;
51    }
52
53    /**
54     * Intercept test failure
55     */
56    @Override
57    public void fireTestFailure(Failure failure) {
58        this.notifier.fireTestFailure(failure);
59        this.testFailure = failure;
60    }
61    
62    public void setFailure(Failure failure) {
63        this.testFailure = failure;
64    }
65
66    /**
67     * Return current test's failure status
68     * 
69     * @return current test's failure status
70     */
71    public boolean isTestFailed() {
72        return this.testFailure != null;
73    }
74    
75    /**
76     * Return current test's failure object
77     * 
78     * @return current test's failure object
79     */
80    public Failure getFailure() {
81        return this.testFailure;
82    }
83
84    /**
85     * Do not fire test finished event until exploration is finished.
86     */
87    @Override
88    public void fireTestFinished(Description description) {
89        // Will be fired when exploration is completed.
90    }
91
92    /**
93     * Fires the test finished event.
94     */
95    public void testExplorationFinished() {
96        this.notifier.fireTestFinished(this.runningTestDescription);
97    }
98
99    /*
100     * (non-Javadoc)
101     * 
102     * @see
103     * org.junit.runner.notification.RunNotifier#fireTestIgnored(org.junit.runner
104     * .Description)
105     */
106    @Override
107    public void fireTestIgnored(Description description) {
108        this.notifier.fireTestIgnored(description);
109    }
110
111    /*
112     * (non-Javadoc)
113     * 
114     * @see
115     * org.junit.runner.notification.RunNotifier#addFirstListener(org.junit.
116     * runner.notification.RunListener)
117     */
118    @Override
119    public void addFirstListener(RunListener listener) {
120        this.notifier.addFirstListener(listener);
121    }
122
123    /*
124     * (non-Javadoc)
125     * 
126     * @see
127     * org.junit.runner.notification.RunNotifier#addListener(org.junit.runner
128     * .notification.RunListener)
129     */
130    @Override
131    public void addListener(RunListener listener) {
132        this.notifier.addListener(listener);
133    }
134
135    /*
136     * (non-Javadoc)
137     * 
138     * @see
139     * org.junit.runner.notification.RunNotifier#fireTestRunFinished(org.junit
140     * .runner.Result)
141     */
142    @Override
143    public void fireTestRunFinished(Result result) {
144        this.notifier.fireTestRunFinished(result);
145    }
146
147    /*
148     * (non-Javadoc)
149     * 
150     * @see
151     * org.junit.runner.notification.RunNotifier#fireTestRunStarted(org.junit
152     * .runner.Description)
153     */
154    @Override
155    public void fireTestRunStarted(Description description) {
156        this.notifier.fireTestRunStarted(description);
157    }
158
159    /*
160     * (non-Javadoc)
161     * 
162     * @see org.junit.runner.notification.RunNotifier#pleaseStop()
163     */
164    @Override
165    public void pleaseStop() {
166        this.notifier.pleaseStop();
167    }
168
169    /*
170     * (non-Javadoc)
171     * 
172     * @see
173     * org.junit.runner.notification.RunNotifier#removeListener(org.junit.runner
174     * .notification.RunListener)
175     */
176    @Override
177    public void removeListener(RunListener listener) {
178        this.notifier.removeListener(listener);
179    }
180
181}
182
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Trigger fireTestRunStarted code on LambdaTest Cloud Grid

Execute automation tests with fireTestRunStarted on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)