public class SimpleJUnitTestListener extends Object implements JUnitTestListener
JUnitTestListener.
This implementation will maintain a count of tests, skipped tests, failures and errors as well as capturing the test JVM's System properties.
This implementation has the functionality to await completion of a test run.
Copyright (c) 2016. All Rights Reserved. Oracle Corporation.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
JUnitTestListener.Event| Constructor and Description |
|---|
SimpleJUnitTestListener()
Create a
SimpleJUnitTestListener. |
| Modifier and Type | Method and Description |
|---|---|
com.oracle.bedrock.Option |
asOption()
Obtain the current
SimpleJUnitTestListener as an Option. |
boolean |
awaitCompletion(long timeout,
TimeUnit unit)
Causes the current thread to wait until the JUnit application
has completed the entire test run, unless the thread is
interrupted, or the specified
waiting time elapses.
|
int |
getErrorCount()
The number of errors running tests.
|
int |
getFailureCount()
The number of test failures.
|
int |
getSkipCount()
The number of tests skipped.
|
int |
getTestCount()
The number of tests executed.
|
Properties |
getTestProperties()
Obtain the System properties of the JVM running the tests.
|
boolean |
hasTestFailures()
Determine whether there were any failures or errors in the test run.
|
void |
junitCompleted(JUnitTestListener.Event event)
Indicates the end of a JUnit application
|
void |
junitStarted(JUnitTestListener.Event event)
Indicates the start of a JUnit application
|
void |
testAssumptionFailure(JUnitTestListener.Event event)
Event fired when a test assumption failure was encountered.
|
void |
testClassFinished(JUnitTestListener.Event event)
Indicates end of a given test-set
|
void |
testClassStarted(JUnitTestListener.Event event)
Indicates the start of a given test-set
|
void |
testError(JUnitTestListener.Event event)
Event fired when a test ended with an error (non anticipated problem)
|
void |
testFailed(JUnitTestListener.Event event)
Event fired when a test ended with a failure (anticipated problem)
|
void |
testIgnored(JUnitTestListener.Event event)
Event fired when a test is skipped
|
void |
testRunFinished(JUnitTestListener.Event event)
Indicates end of a given test-set
|
void |
testRunStarted(JUnitTestListener.Event event)
Indicates the start of a given test-set
|
void |
testStarted(JUnitTestListener.Event event)
Event fired when a test is about to start
|
void |
testSucceeded(JUnitTestListener.Event event)
Event fired when a test ended successfully
|
public SimpleJUnitTestListener()
SimpleJUnitTestListener.public Properties getTestProperties()
public int getTestCount()
This figure only includes tests actually started so will
not include tests annotated with Ignore
but will include tests skipped due to an Assume
exception.
public int getSkipCount()
This figure includes both tests annotated
with Ignore and tests
skipped due to an Assume
exception.
public int getFailureCount()
This is the number of tests that failed due
to an AssertionError.
public int getErrorCount()
This is the number of tests that failed due
to an exception other than an AssertionError.
public boolean hasTestFailures()
true if there were any failures or errors in the test
run, or returns false if all tests completed successfullypublic boolean awaitCompletion(long timeout,
TimeUnit unit)
throws InterruptedException
If the JUnit application has already completed then this method
returns immediately with the value true.
If JUnit application has not yet completed then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of three things happen:
If the JUnit application completes the test run then the
method returns with the value true.
If the current thread:
InterruptedException is thrown and the current thread's
interrupted status is cleared.
If the specified waiting time elapses then the value false
is returned. If the time is less than or equal to zero, the method
will not wait at all.
timeout - the maximum time to waitunit - the time unit of the timeout argumenttrue if the JUnit application completed the test
run and false if the waiting time elapsed before
the JUnit application completedInterruptedException - if the current thread is interrupted
while waitingpublic com.oracle.bedrock.Option asOption()
SimpleJUnitTestListener as an Option.SimpleJUnitTestListener as an Optionpublic void junitStarted(JUnitTestListener.Event event)
JUnitTestListenerjunitStarted in interface JUnitTestListenerevent - the eventpublic void junitCompleted(JUnitTestListener.Event event)
JUnitTestListenerjunitCompleted in interface JUnitTestListenerevent - the eventpublic void testRunStarted(JUnitTestListener.Event event)
JUnitTestListenertestRunStarted in interface JUnitTestListenerevent - the report entry describing the test suitepublic void testRunFinished(JUnitTestListener.Event event)
JUnitTestListenertestRunFinished in interface JUnitTestListenerevent - the report entry describing the test suitetpublic void testStarted(JUnitTestListener.Event event)
JUnitTestListenertestStarted in interface JUnitTestListenerevent - The report entry to log forpublic void testClassStarted(JUnitTestListener.Event event)
JUnitTestListenertestClassStarted in interface JUnitTestListenerevent - the report entry describing the test suitepublic void testClassFinished(JUnitTestListener.Event event)
JUnitTestListenertestClassFinished in interface JUnitTestListenerevent - the report entry describing the test suitepublic void testSucceeded(JUnitTestListener.Event event)
JUnitTestListenertestSucceeded in interface JUnitTestListenerevent - The report entry to log forpublic void testIgnored(JUnitTestListener.Event event)
JUnitTestListenertestIgnored in interface JUnitTestListenerevent - The report entry to log forpublic void testFailed(JUnitTestListener.Event event)
JUnitTestListenertestFailed in interface JUnitTestListenerevent - The report entry to log forpublic void testError(JUnitTestListener.Event event)
JUnitTestListenertestError in interface JUnitTestListenerevent - The report entry to log forpublic void testAssumptionFailure(JUnitTestListener.Event event)
JUnitTestListenertestAssumptionFailure in interface JUnitTestListenerevent - The report entry to log forCopyright © 2017. All rights reserved.