enum Quality extends Enum<Quality>
TestCase
from being Scheduled to Ignored
or via Started to finished
which means either Invalidated, Success,
Failure or even Error.
The phase transitions are triggered by the events
notified by a RunListener as depicted below.
|RunListener.testRunStarted(Description)
|
Scheduled
/|
/ |
#testIgnored(Description)/ |RunListener.testStarted(Description)
/ |
/ |
Ignored |
|
Started
/|\
#testFinished(Description)/ |#testAssumptionFailure(Failure)
/ | \
/ | \
_______________/ | \__________
/ | \
/ RunListener.testFailure(Failure) \
/ /\ \
/ / \ \
/ / \ \
Success Failure Error Invalidated.
Accordingly,
there are methods setXXX for transition to the next state:
setScheduled(), setStarted() prior to testing,
setIgnored() if not to be tested and
setFinished(), setAssumptionFailure() and
setFailure(Throwable)
after the test finished.
All these methods prevent invalid phase transitions
throwin an IllegalStateException.
For each of these phases, there are methods to represent the quality or further aspects of a testcase graphically: Each Quality defines
getIcon(),
getMessage()
getColor() influencing the color of the progress bar
setTime(long) to compute the time
required for a test run.
isNeutral() and hasFailure().
Created: Wed Jun 12 16:41:14 2006| Enum Constant and Description |
|---|
Error
The execution of the testcase failed
indicated by finishing with exception or error
other than
AssertionFailedError. |
Failure
The execution of the testcase finished gracefully
but did not succeed:
At least one assertion is hurt,
indicated by an
AssertionFailedError. |
Ignored
The testcase was ignored, i.e. was scheduled for execution
but then decided not to start execution.
|
Invalidated
The execution of the testcase ran onto an hurt assumption
before maybe running into further exceptions or errors
and is thus invalidated.
|
Scheduled
The testcase is scheduled for execution
but execution has not yet been started
nor has it been decided to ignore, i.e. not to execute the testcase.
|
Started
The execution of the testcase started but did not finish
in any way.
|
Success
The execution of the testcase finished and the test succeeded (passed):
All assertions hold and no throwable has been thrown.
|
| Modifier and Type | Field and Description |
|---|---|
private static Color |
COLOR_FAIL
Represents a failed testcase.
|
private static Color |
COLOR_IGNORED
Represents an ignored testcase.
|
private static Color |
COLOR_OK
Represents a testcase which did neither failed.
|
private int |
level
|
| Modifier and Type | Method and Description |
|---|---|
(package private) Color |
getColor()
Returns the color associated with this phase:
If this phase represents an irregular ending testcase,
COLOR_FAIL is returned. |
(package private) abstract ImageIcon |
getIcon()
Returns an icon representing this phase on the GUI.
|
(package private) abstract String |
getMessage()
Returns a status message which describes this phase.
|
(package private) boolean |
hasFailure()
Returns whether the given state is tied to a throwable.
|
(package private) boolean |
isNeutral()
Returns whether the underlying testcase is
neither finished unsuccessfully nor ignored.
|
(package private) Quality |
max(Quality other)
Determines a Quality with the maximum level
of
this and other. |
(package private) Quality |
setAssumptionFailure()
Returns the next phase
when
RunListener.testAssumptionFailure(Failure) is invoked. |
(package private) Quality |
setFailure(Throwable thrw)
Returns the next phase
when
RunListener.testFailure(Failure) is invoked. |
(package private) Quality |
setFinished()
Returns the next phase
when
RunListener.testFinished(Description) is invoked. |
(package private) Quality |
setIgnored()
Returns the next phase
when
RunListener.testIgnored(Description) is invoked. |
(package private) Quality |
setScheduled()
Returns the next phase
when
RunListener.testRunStarted(Description) is invoked. |
(package private) Quality |
setStarted()
Returns the next phase
when
RunListener.testStarted(Description) is invoked. |
(package private) long |
setTime(long time)
Returns the difference of the current time in milliseconds.
|
static Quality |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static Quality[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final Quality Scheduled
public static final Quality Started
public static final Quality Success
public static final Quality Invalidated
public static final Quality Ignored
public static final Quality Failure
AssertionFailedError.
This excludes further throwables.public static final Quality Error
AssertionFailedError.
Thus there is no valid test result.private int level
max(Quality)private static final Color COLOR_FAIL
private static final Color COLOR_OK
private static final Color COLOR_IGNORED
public static Quality[] values()
for (Quality c : Quality.values()) System.out.println(c);
public static Quality valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullQuality setScheduled()
RunListener.testRunStarted(Description) is invoked.Scheduled except this is Started.
Even for Scheduled itself.IllegalStateException - for Started.
**** it is a decision to disallow rescheduling a running testcase.Quality setStarted()
RunListener.testStarted(Description) is invoked.Started if this is Scheduled.IllegalStateException - except if this is ScheduledQuality setIgnored()
RunListener.testIgnored(Description) is invoked.Ignored if this is Scheduled.IllegalStateException - except for Scheduled.Quality setFinished()
RunListener.testFinished(Description) is invoked.this
for Failure, Invalidated and Error
Success for Started.
IllegalStateException - for Scheduled, Success and Ignored.Quality setAssumptionFailure()
RunListener.testAssumptionFailure(Failure) is invoked.Invalidated for Started.IllegalStateException - for all but Started.Quality setFailure(Throwable thrw)
RunListener.testFailure(Failure) is invoked.thrw - a throwable which determines
whether the returned phase indicates a failure or an error.Failure or Error for Started
depending on whether thrw
is an AssertionError
(should be AssertionFailedError).IllegalStateException - for all but Started.
If this is Started
but failure is an AssumptionViolatedException.abstract ImageIcon getIcon()
abstract String getMessage()
Quality max(Quality other)
this and other.
In conjunction with getColor(),
this is used to determine the color of the progress bar in a JUnit GUIthis and other.GUIRunner.TestProgressBar.noteReportResult(TestCase)Color getColor()
COLOR_FAIL is returned.
Else if this phase represents an ignored testcase,
COLOR_IGNORED is returned.
Else COLOR_OK is returned.max(Quality)long setTime(long time)
time - some time in milliseconds.
The details depend on this:
-1 for Scheduled.
-0 for Ignored.
System.currentTimeMillis()
for Started.
boolean isNeutral()
false
except for Scheduled, Started and Success.
Neutral qualities do not occur in the statistics
given by GUIRunner.StatisticsTestState.boolean hasFailure()
true iff this is
Invalidated, Failure or Error.Copyright © 2012–2018 Simuline Organization (l2r). All rights reserved.