Class GenericVerifications<T extends AnyScenarioType,SELF extends GenericVerifications<T,SELF>>
- java.lang.Object
-
- com.tngtech.jgiven.base.StageBase<SELF>
-
- com.tngtech.jgiven.Stage<SELF>
-
- dev.aherscu.qa.jgiven.commons.utils.StageEx<SELF>
-
- dev.aherscu.qa.jgiven.commons.steps.GenericVerifications<T,SELF>
-
- Type Parameters:
SELF
- the type of the subclassT
- type of scenario
- All Implemented Interfaces:
ScenarioType<T>
@ThreadSafe public class GenericVerifications<T extends AnyScenarioType,SELF extends GenericVerifications<T,SELF>> extends StageEx<SELF> implements ScenarioType<T>
Generic verifications.- Author:
- aherscu
-
-
Field Summary
-
Fields inherited from class dev.aherscu.qa.jgiven.commons.utils.StageEx
assertElementTimer, ATTACHEMENT_TRANSFORMER, clickTimer, currentStep, locateTimer, pollDelay, pollTimeout, retryPolicy, scrollIntoViewTimer, sendKeysTimer
-
-
Constructor Summary
Constructors Constructor Description GenericVerifications()
Logs the construction of this stage.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
beforeScenarioConfigurePolling()
Configures the retry policy.SELF
eventually(StepWithDescription<SELF> step, net.jodah.failsafe.Policy<SELF>... additionalRetryPolicies)
Executes specified step on same thread, and repeats it uponAssertionError
.SELF
eventually(Function<SELF,SELF> step, net.jodah.failsafe.Policy<SELF>... additionalRetryPolicies)
Repeatedly executes specified block on same thread, verifying its outcome matches the expected.<V> SELF
eventually_assert_that(Supplier<V> objectToBeAsserted, org.hamcrest.Matcher<V> matcher, net.jodah.failsafe.Policy<SELF>... additionalRetryPolicies)
Asserts supplied object matches specified matcher on same thread.SELF
should_succeed(org.hamcrest.Matcher<Boolean> matcher)
Verifies that the expected is true.SELF
the_file_$_should_contain(File file, String contents)
Verifies the contents of the specified file.SELF
the_file_$_should_match(File file, org.hamcrest.Matcher<String> expected)
Verifies the contents of the specified file.SELF
the_JSON_file_$_should_contain(File jsonFile, Iterable<? extends dev.aherscu.qa.testing.utils.assertions.JsonAssertion<?>> expectedContents)
Verifies the contents of the specified JSON file.-
Methods inherited from class dev.aherscu.qa.jgiven.commons.utils.StageEx
alert, attach, attachScreenshot, attachScreenshot, attachScreenshot, context, element, elements, ensureElements, retry, safely, scrollIntoView
-
-
-
-
Method Detail
-
eventually
@SafeVarargs public final SELF eventually(Function<SELF,SELF> step, net.jodah.failsafe.Policy<SELF>... additionalRetryPolicies)
Repeatedly executes specified block on same thread, verifying its outcome matches the expected.- Parameters:
step
- the block to executeadditionalRetryPolicies
- additional retry policies- Returns:
StageBase.self()
- Throws:
AssertionError
- if the supplied object does not match
-
eventually
@SafeVarargs public final SELF eventually(StepWithDescription<SELF> step, net.jodah.failsafe.Policy<SELF>... additionalRetryPolicies)
Executes specified step on same thread, and repeats it uponAssertionError
. The interval and duration of these repetitions are configured viabeforeScenarioConfigurePolling()
.- Parameters:
step
- the block to executeadditionalRetryPolicies
- additional retry policies- Returns:
StageBase.self()
- Throws:
AssertionError
- if the supplied object does not match- See Also:
beforeScenarioConfigurePolling()
-
eventually_assert_that
@SafeVarargs public final <V> SELF eventually_assert_that(Supplier<V> objectToBeAsserted, org.hamcrest.Matcher<V> matcher, net.jodah.failsafe.Policy<SELF>... additionalRetryPolicies)
Asserts supplied object matches specified matcher on same thread. UponAssertionError
, asks for updated object and asserts again. Ignores all exceptions. The interval and duration of these assertions are configured viabeforeScenarioConfigurePolling()
.- Type Parameters:
V
- the type of object to assert upon- Parameters:
objectToBeAsserted
- the supplied object to assert uponmatcher
- the matcheradditionalRetryPolicies
- additional retry policies- Returns:
StageBase.self()
- Throws:
AssertionError
- if the supplied object does not match- See Also:
beforeScenarioConfigurePolling()
-
should_succeed
public SELF should_succeed(org.hamcrest.Matcher<Boolean> matcher)
Verifies that the expected is true.- Parameters:
matcher
- the matching rule- Returns:
StageBase.self()
-
the_JSON_file_$_should_contain
@As("the JSON file $ should contain") public SELF the_JSON_file_$_should_contain(File jsonFile, Iterable<? extends dev.aherscu.qa.testing.utils.assertions.JsonAssertion<?>> expectedContents)
Verifies the contents of the specified JSON file.- Parameters:
jsonFile
- the JSON fileexpectedContents
- the expected contents- Returns:
StageBase.self()
-
the_file_$_should_contain
public SELF the_file_$_should_contain(File file, String contents)
Verifies the contents of the specified file.IMPORTANT: not suitable for large files
- Parameters:
file
- the type of IDX filecontents
- the contents- Returns:
StageBase.self()
-
the_file_$_should_match
public SELF the_file_$_should_match(File file, org.hamcrest.Matcher<String> expected)
Verifies the contents of the specified file.IMPORTANT: not suitable for large files
- Parameters:
file
- the type of IDX fileexpected
- the contents to match- Returns:
StageBase.self()
-
beforeScenarioConfigurePolling
protected void beforeScenarioConfigurePolling()
Description copied from class:StageEx
Configures the retry policy. Configurable via:- poll.delay -- defaults to 1 second
- poll.timeout -- defaults to 10 seconds
IMPORTANT: if you override this method, you should ensure that other policy properties are setup properly, either by calling this implementation via
super.configureRetryPolicy()
, or by other means.- Overrides:
beforeScenarioConfigurePolling
in classStageEx<SELF extends GenericVerifications<T,SELF>>
-
-