Package io.github.imagineDevit.giwt.core
Class ATestCase<T,R,STATE extends ATestCaseState<T>,RESULT extends ATestCaseResult<R>>
java.lang.Object
io.github.imagineDevit.giwt.core.CloseableCase
io.github.imagineDevit.giwt.core.ATestCase<T,R,STATE,RESULT>
- Type Parameters:
T-R-
public abstract class ATestCase<T,R,STATE extends ATestCaseState<T>,RESULT extends ATestCaseResult<R>>
extends CloseableCase
Test case abstract class.
- Since:
- 0.0.1
- Author:
- Henri Joel SEDJAME
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumTest case result that can be either success or failure -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected GivenRFnprotected final Stringprotected final TestParameters.Parameterprotected final TestCaseReport.TestReportprotected RESULTprotected STATEprotected WhenRFn -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedATestCase(String name, TestCaseReport.TestReport report, TestParameters.Parameter parameters) Constructor -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAdds another Given statement to the current test case with the provided message and function.protected voidAdds a then statement to the current test case with the provided message and a consumer function.protected StringgetName()Returns the name of the test case with its relevant parameters formatted.Creates a new Given statement with the provided message and (runnable) function.Creates a new Given statement with the provided message and (supplier) function.protected abstract RESULTprotected abstract RESULTprotected voidrun()protected abstract STATEprotected abstract RESULTstateToResult(Function<T, R> mapper) Adds a Then statement to the current test case with the provided message and a consumer function.Adds a When statement to the current test case with the provided message and a function.Adds a When statement to the current test case with the provided message and a runnable functionAdds a When statement to the current test case with the provided message and a supplier function.Adds a When statement to the current test case with the provided message and a runnable functionAdds a When statement to the current test case with the provided message and a function.Methods inherited from class io.github.imagineDevit.giwt.core.CloseableCase
runIfOpen
-
Field Details
-
name
-
report
-
parameters
-
andGivenFns
-
whenFns
-
thenFns
-
givenMsgs
-
whenMsgs
-
thenMsgs
-
state
-
result
-
givenFn
-
givenRFn
-
whenFn
-
whenRFn
-
whenCFn
-
-
Constructor Details
-
ATestCase
protected ATestCase(String name, TestCaseReport.TestReport report, TestParameters.Parameter parameters) Constructor- Parameters:
name- the testCase namereport- the test reportparameters- the test parameters
-
-
Method Details
-
given
public <TC extends ATestCase<T,R, AGivenStmt<T,STATE, RESULT>> R, givenSTATE, RESULT, TC> (String message, GivenSFn<T> fn) Creates a new Given statement with the provided message and (supplier) function.- Parameters:
message- the description of the statement being givenfn- the function that executes the given statement- Returns:
- the Given statement object
-
given
-
given
public <TC extends ATestCase<T,R, AGivenStmt<T,STATE, RESULT>> R, givenSTATE, RESULT, TC> (String message, GivenRFn fn) Creates a new Given statement with the provided message and (runnable) function.- Parameters:
message- the description of the statement being givenfn- the function that executes the given statement- Returns:
- the Given statement object
-
when
public <TC extends ATestCase<T,R, AWhenStmt<T,STATE, RESULT>> R, whenSTATE, RESULT, TC> (String message, WhenSFn<R> fn) Adds a When statement to the current test case with the provided message and a supplier function.- Parameters:
message- the description of the new When statementfn- the function that executes the When statement- Returns:
- a new instance of WhenStmt that is associated with this test case
-
when
public <TC extends ATestCase<T,R, AWhenStmt<T,STATE, RESULT>> R, whenSTATE, RESULT, TC> (String message, WhenRFn fn) Adds a When statement to the current test case with the provided message and a runnable function- Parameters:
message- the description of the new When statementfn- the function that executes the When statement- Returns:
- a new instance of WhenStmt that is associated with this test case
-
andGiven
Adds another Given statement to the current test case with the provided message and function.- Parameters:
message- the description of the new Given statementfn- the function that executes the given statement
-
when
protected <TC extends ATestCase<T,R, AWhenStmt<T,STATE, RESULT>> R, whenSTATE, RESULT, TC> (String message, WhenFFn<T, R> fn) Adds a When statement to the current test case with the provided message and a function.- Parameters:
message- the description of the new When statementfn- the function that executes the When statement and returns a result of type R- Returns:
- a new instance of WhenStmt that is associated with this test case
-
whenc
protected <TC extends ATestCase<T,R, AWhenStmt<T,STATE, RESULT>> R, whencSTATE, RESULT, TC> (String message, WhenCFn<T> fn) Adds a When statement to the current test case with the provided message and a runnable function- Parameters:
message- the description of the new When statementfn- the function that executes the When statement- Returns:
- a new instance of WhenStmt that is associated with this test case
-
whenr
protected <TC extends ATestCase<T,R, AWhenStmt<T,STATE, RESULT>> R, whenrSTATE, RESULT, TC> (String message, WhenRFn fn) Adds a When statement to the current test case with the provided message and a function.- Parameters:
message- the description of the new When statementfn- the function that executes the When statement and returns a result of type R- Returns:
- a new instance of WhenStmt that is associated with this test case
-
then
protected <TC extends ATestCase<T,R, AThenStmt<T,STATE, RESULT>> R, thenSTATE, RESULT, TC> (String message, ThenFn<R, RESULT> fn) Adds a Then statement to the current test case with the provided message and a consumer function.- Parameters:
message- the description of the new Then statementfn- the function that executes the Then statement- Returns:
- a new instance of ThenStmt that is associated with this test case
-
andThen
Adds a then statement to the current test case with the provided message and a consumer function. This method is used in conjunction with the initial ThenStmt method, allowing for multiple Then statements in a single test case.- Parameters:
message- the description of the new Then statementfn- the function that executes the additional Then statement
-
run
protected void run() -
getName
Returns the name of the test case with its relevant parameters formatted. If the test case has parameters, it will format the name using the parameters. If not, it will return the name as is. Note: This method is protected, which means it can only be accessed by classes within the same package or subclasses.- Returns:
- the formatted name of the test case.
-
stateOf
-
stateToResult
-
resultOf
-
resultOfErr
-