Package de.rwth.swc.coffee4j.engine
Class TestResult
- java.lang.Object
-
- de.rwth.swc.coffee4j.engine.TestResult
-
public final class TestResult extends java.lang.ObjectSpecifies 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.
-
-
Constructor Summary
Constructors Constructor Description TestResult()Creates a new result for a successful test.TestResult(java.lang.Throwable causeForFailure)Creates a new result for a successful test if the exception isnull, or a failed test otherwise.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object object)static TestResultfailure(java.lang.Throwable causeForFailure)Descriptive convenience method for constructing a result for a failed test input.java.util.Optional<java.lang.Throwable>getCauseForFailure()inthashCode()booleanisSuccessful()booleanisUnsuccessful()static TestResultsuccess()Descriptive convenience method for constructing a result for a successful test input.java.lang.StringtoString()
-
-
-
Constructor Detail
-
TestResult
public TestResult()
Creates a new result for a successful test.
-
TestResult
public TestResult(java.lang.Throwable causeForFailure)
Creates a new result for a successful test if the exception isnull, or a failed test otherwise.- Parameters:
causeForFailure- the exception which caused the failure
-
-
Method Detail
-
success
public static TestResult success()
Descriptive convenience method for constructing a result for a successful test input.- Returns:
- a successful result
-
failure
public static TestResult failure(java.lang.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)
-
isUnsuccessful
public boolean isUnsuccessful()
- Returns:
- whether the result indicates failure (exception given)
-
getCauseForFailure
public java.util.Optional<java.lang.Throwable> getCauseForFailure()
- Returns:
- an optional containing the exception which caused the failure or an empty optional if the test was successful
-
equals
public boolean equals(java.lang.Object object)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-