Package eu.simuline.testhelpers
Enum Quality
- java.lang.Object
-
- java.lang.Enum<Quality>
-
- eu.simuline.testhelpers.Quality
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<Quality>
enum Quality extends java.lang.Enum<Quality>
Represents the phases in the life-cycle of aTestCase
from beingScheduled
toIgnored
or viaStarted
to finished which means eitherInvalidated
,Success
,Failure
or evenError
.The phase transitions are triggered by the events notified by a
RunListener
as depicted below.|
Accordingly, there are methodsRunListener.testRunStarted(Description)
|Scheduled
/| / |#testIgnored(Description)
/ |RunListener.testStarted(Description)
/ | / |Ignored
| |Started
/|\#testFinished(Description)
/ |#testAssumptionFailure(Failure)
/ | \ / | \ _______________/ | \__________ / | \ /RunListener.testFailure(Failure)
\ / /\ \ / / \ \ / / \ \Success
Failure
Error
Invalidated
.setXXX
for transition to the next state:setScheduled()
,setStarted()
prior to testing,setIgnored()
if not to be tested andsetFinished()
,setAssumptionFailure()
andsetFailure(Throwable)
after the test finished. All these methods prevent invalid phase transitions throwin anIllegalStateException
.For each of these phases, there are methods to represent the quality or further aspects of a testcase graphically: Each Quality defines
- a separate icon given by
getIcon()
, - a status message given by
getMessage()
- a color
getColor()
influencing the color of the progress bar - a method
setTime(long)
to compute the time required for a test run.
isNeutral()
andhasFailure()
. Created: Wed Jun 12 16:41:14 2006- Version:
- 1.0
- Author:
- Ernst Reissner
-
-
Enum Constant Summary
Enum Constants Enum Constant Description Error
The execution of the testcase failed indicated by finishing with exception or error other thanAssertionFailedError
.Failure
The execution of the testcase finished gracefully but did not succeed: At least one assertion is hurt, indicated by anAssertionFailedError
.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.
-
Field Summary
Fields Modifier and Type Field Description private static java.awt.Color
COLOR_FAIL
Represents a failed testcase.private static java.awt.Color
COLOR_IGNORED
Represents an ignored testcase.private static java.awt.Color
COLOR_OK
Represents a testcase which did neither failed.private int
level
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) java.awt.Color
getColor()
Returns the color associated with this phase: If this phase represents an irregular ending testcase,COLOR_FAIL
is returned.(package private) abstract javax.swing.ImageIcon
getIcon()
Returns an icon representing this phase on the GUI.(package private) abstract java.lang.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 ofthis
andother
.(package private) Quality
setAssumptionFailure()
Returns the next phase whenRunListener.testAssumptionFailure(Failure)
is invoked.(package private) Quality
setFailure(java.lang.Throwable thrw)
Returns the next phase whenRunListener.testFailure(Failure)
is invoked.(package private) Quality
setFinished()
Returns the next phase whenRunListener.testFinished(Description)
is invoked.(package private) Quality
setIgnored()
Returns the next phase whenRunListener.testIgnored(Description)
is invoked.(package private) Quality
setScheduled()
Returns the next phase whenRunListener.testRunStarted(Description)
is invoked.(package private) Quality
setStarted()
Returns the next phase whenRunListener.testStarted(Description)
is invoked.(package private) long
setTime(long time)
Returns the difference of the current time in milliseconds.static Quality
valueOf(java.lang.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.
-
-
-
Enum Constant Detail
-
Scheduled
public static final Quality 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
public static final Quality Started
The execution of the testcase started but did not finish in any way. Thus it is neither clear whether the execution succeeds nor the outcoming of the test.
-
Success
public static final Quality Success
The execution of the testcase finished and the test succeeded (passed): All assertions hold and no throwable has been thrown.
-
Invalidated
public static final Quality Invalidated
The execution of the testcase ran onto an hurt assumption before maybe running into further exceptions or errors and is thus invalidated.
-
Ignored
public static final Quality Ignored
The testcase was ignored, i.e. was scheduled for execution but then decided not to start execution. In particular, nothing can be said about the course of the test run.
-
Failure
public static final Quality Failure
The execution of the testcase finished gracefully but did not succeed: At least one assertion is hurt, indicated by anAssertionFailedError
. This excludes further throwables.
-
Error
public static final Quality Error
The execution of the testcase failed indicated by finishing with exception or error other thanAssertionFailedError
. Thus there is no valid test result.
-
-
Field Detail
-
level
private int level
Encoding how good the result of the test is: This is used to define the color of the progress bar.- See Also:
max(Quality)
-
COLOR_FAIL
private static final java.awt.Color COLOR_FAIL
Represents a failed testcase.
-
COLOR_OK
private static final java.awt.Color COLOR_OK
Represents a testcase which did neither failed.
-
COLOR_IGNORED
private static final java.awt.Color COLOR_IGNORED
Represents an ignored testcase.
-
-
Constructor Detail
-
Quality
private Quality(int level)
Creates another Quality with the given levellevel
.
-
-
Method Detail
-
values
public static Quality[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (Quality c : Quality.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static Quality valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
setScheduled
Quality setScheduled()
Returns the next phase whenRunListener.testRunStarted(Description)
is invoked.
-
setStarted
Quality setStarted()
Returns the next phase whenRunListener.testStarted(Description)
is invoked.
-
setIgnored
Quality setIgnored()
Returns the next phase whenRunListener.testIgnored(Description)
is invoked.
-
setFinished
Quality setFinished()
Returns the next phase whenRunListener.testFinished(Description)
is invoked.
-
setAssumptionFailure
Quality setAssumptionFailure()
Returns the next phase whenRunListener.testAssumptionFailure(Failure)
is invoked.- Returns:
Invalidated
forStarted
.- Throws:
java.lang.IllegalStateException
- for all butStarted
.
-
setFailure
Quality setFailure(java.lang.Throwable thrw)
Returns the next phase whenRunListener.testFailure(Failure)
is invoked.- Parameters:
thrw
- a throwable which determines whether the returned phase indicates a failure or an error.- Returns:
Failure
orError
forStarted
depending on whetherthrw
is anAssertionError
(should beAssertionFailedError
).- Throws:
java.lang.IllegalStateException
- for all butStarted
. If this isStarted
butfailure
is anAssumptionViolatedException
.
-
getIcon
abstract javax.swing.ImageIcon getIcon()
Returns an icon representing this phase on the GUI.- Returns:
- an icon representing this phase on the GUI.
-
getMessage
abstract java.lang.String getMessage()
Returns a status message which describes this phase.- Returns:
- a status message which describes this phase.
-
max
Quality max(Quality other)
Determines a Quality with the maximum level ofthis
andother
. In conjunction withgetColor()
, this is used to determine the color of the progress bar in a JUnit GUI- Returns:
- the Quality with the maximum level
of
this
andother
. - See Also:
GUIRunner.TestProgressBar.noteReportResult(TestCase)
-
getColor
java.awt.Color getColor()
Returns the color associated with this phase: If this phase represents an irregular ending testcase,COLOR_FAIL
is returned. Else if this phase represents an ignored testcase,COLOR_IGNORED
is returned. ElseCOLOR_OK
is returned.- Returns:
- the color associated with this phase.
- See Also:
max(Quality)
-
setTime
long setTime(long time)
Returns the difference of the current time in milliseconds.- Parameters:
time
- some time in milliseconds. The details depend on this:- Returns:
-
isNeutral
boolean isNeutral()
Returns whether the underlying testcase is neither finished unsuccessfully nor ignored. This isfalse
except forScheduled
,Started
andSuccess
. Neutral qualities do not occur in the statistics given byGUIRunner.StatisticsTestState
.- Returns:
- whether the underlying testcase is neither finished unsuccessfully nor ignored.
-
hasFailure
boolean hasFailure()
Returns whether the given state is tied to a throwable.- Returns:
true
iff this isInvalidated
,Failure
orError
.
-
-