Class TestResult
- java.lang.Object
-
- de.rwth.swc.coffee4j.algorithmic.model.TestResult
-
public final class TestResult extends Object
Specifies the result of a test. Either a test threw no exception and was therefore successful, or it has an exception as a cause for failure.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object object)
static TestResult
exceptionalSuccess(Throwable exception)
Descriptive convenience method for constructing a result for a exceptional-successful test input.static TestResult
failure(Throwable causeForFailure)
Descriptive convenience method for constructing a result for a failed test input.Throwable
getRequiredResultValue()
Optional<Throwable>
getResultValue()
int
hashCode()
boolean
isExceptionalSuccessful()
boolean
isSuccessful()
boolean
isUnsuccessful()
static TestResult
success()
Descriptive convenience method for constructing a result for a successful test input.String
toString()
-
-
-
Method Detail
-
success
public static TestResult success()
Descriptive convenience method for constructing a result for a successful test input.- Returns:
- a successful result
-
exceptionalSuccess
public static TestResult exceptionalSuccess(Throwable exception)
Descriptive convenience method for constructing a result for a exceptional-successful test input.- Parameters:
exception
- thrownErrorConstraintException
- Returns:
- an exceptional-successful result
-
failure
public static TestResult failure(Throwable causeForFailure)
Descriptive convenience method for constructing a result for a failed test input.- Parameters:
causeForFailure
- the exception which caused the test to fail, or indicates that it has failed- Returns:
- a failed result
-
isSuccessful
public boolean isSuccessful()
- Returns:
- whether the result indicates success (no exception given)
-
isExceptionalSuccessful
public boolean isExceptionalSuccessful()
- Returns:
- whether the result indicates an exceptional-success (
ErrorConstraintException
given)
-
isUnsuccessful
public boolean isUnsuccessful()
- Returns:
- whether the result indicates failure (exception given and not an
ErrorConstraintException
)
-
getResultValue
public Optional<Throwable> getResultValue()
- Returns:
- an optional containing the exception which caused the failure or an empty optional if the test was successful
-
getRequiredResultValue
public Throwable getRequiredResultValue()
- Returns:
- the required exception which caused the failure. Never
null
- Throws:
NullPointerException
- if there was no exception (e.g. if the test was successful)
-
-