Package de.qytera.qtaf.cucumber.context
Class QtafTestNGCucumberContext
java.lang.Object
io.cucumber.testng.AbstractTestNGCucumberTests
de.qytera.qtaf.cucumber.context.QtafTestNGCucumberContext
- All Implemented Interfaces:
IQtafTestContext
@Guice(modules=QtafModule.class)
public class QtafTestNGCucumberContext
extends io.cucumber.testng.AbstractTestNGCucumberTests
implements IQtafTestContext
Cucumber Test Contexts.
Cucumber runner classes need to extend this class
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic ConfigMapHolds values from JSON configuration files.static org.openqa.selenium.WebDriverWeb driver instance (chrome, firefox, ...).protected TestScenarioLogCollectionLog collection for the current method.protected TestFeaturePage object annotation reference.protected TestFeatureLogCollectionLog collection for all methods in this class.static final TestSuiteLogCollectionGlobal log collection that holds all log messages from the tests. -
Constructor Summary
ConstructorsConstructorDescriptionConstructor with initialization.QtafTestNGCucumberContext(boolean shallInitialize) Constructor with optional initialization. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd logger to all instance fields.voidafterStep(io.cucumber.java.Scenario scenario) Step hooks invoked before and after a step.voidbeforeStep(io.cucumber.java.Scenario scenario) Step hooks invoked before and after a step.voidembedScreenshot(io.cucumber.java.Scenario scenario) After hooks run after the last step of each scenario, even when the step result is failed, undefined, pending, or skipped.Get current log collection.Initialize test context.voidinitializeTest(io.cucumber.java.Scenario scenario) Before hooks run before the first step of each scenario.protected voidonBeforeScenario(QTAFCucumberScenarioEntity scenarioEntity) Method that runs before each scenario.voidDestroys the current browser and starts a new one.voidrunScenario(io.cucumber.testng.PickleWrapper pickleWrapper, io.cucumber.testng.FeatureWrapper featureWrapper) TestNG test that executes all cucumber scenarios.Object[][]Method that loads and provides Cucumber Scenario entities.setLogCollection(TestScenarioLogCollection collection) Set the current log collection.booleanshallRun(QTAFCucumberScenarioEntity scenarioEntity) Method that check if a scenario shall run or not.Methods inherited from class io.cucumber.testng.AbstractTestNGCucumberTests
setUpClass, tearDownClass
-
Field Details
-
config
Holds values from JSON configuration files. -
driver
public static org.openqa.selenium.WebDriver driverWeb driver instance (chrome, firefox, ...). -
testFeatureAnnotation
Page object annotation reference. -
testSuiteLogCollection
Global log collection that holds all log messages from the tests. -
logCollection
Log collection for the current method. -
testFeatureLogCollection
Log collection for all methods in this class.
-
-
Constructor Details
-
QtafTestNGCucumberContext
public QtafTestNGCucumberContext()Constructor with initialization. -
QtafTestNGCucumberContext
public QtafTestNGCucumberContext(boolean shallInitialize) Constructor with optional initialization.- Parameters:
shallInitialize- Whether test context should be initialized or not
-
-
Method Details
-
restartDriver
public void restartDriver()Description copied from interface:IQtafTestContextDestroys the current browser and starts a new one.- Specified by:
restartDriverin interfaceIQtafTestContext
-
initialize
Description copied from interface:IQtafTestContextInitialize test context.- Specified by:
initializein interfaceIQtafTestContext- Returns:
- this
-
getLogCollection
Description copied from interface:IQtafTestContextGet current log collection.- Specified by:
getLogCollectionin interfaceIQtafTestContext- Returns:
- log collection
-
setLogCollection
Description copied from interface:IQtafTestContextSet the current log collection.- Specified by:
setLogCollectionin interfaceIQtafTestContext- Parameters:
collection- log collection- Returns:
- this
-
addLoggerToFieldsRecursively
public void addLoggerToFieldsRecursively()Description copied from interface:IQtafTestContextAdd logger to all instance fields.- Specified by:
addLoggerToFieldsRecursivelyin interfaceIQtafTestContext
-
initializeTest
public void initializeTest(io.cucumber.java.Scenario scenario) Before hooks run before the first step of each scenario.- Parameters:
scenario- the scenario
-
shallRun
Method that check if a scenario shall run or not.- Parameters:
scenarioEntity- Scenario entity object- Returns:
- true if scenario shall run, false otherwise
-
scenarios
Method that loads and provides Cucumber Scenario entities.- Overrides:
scenariosin classio.cucumber.testng.AbstractTestNGCucumberTests- Returns:
- Cucumber scenario entities
-
runScenario
public void runScenario(io.cucumber.testng.PickleWrapper pickleWrapper, io.cucumber.testng.FeatureWrapper featureWrapper) TestNG test that executes all cucumber scenarios.- Overrides:
runScenarioin classio.cucumber.testng.AbstractTestNGCucumberTests- Parameters:
pickleWrapper- Cucumber scenario entity wrapperfeatureWrapper- Cucumber feature entity wrapper
-
onBeforeScenario
Method that runs before each scenario.- Parameters:
scenarioEntity- Entity object that holds information about feature and scenario that gets executed
-
beforeStep
public void beforeStep(io.cucumber.java.Scenario scenario) Step hooks invoked before and after a step.- Parameters:
scenario- the scenario
-
afterStep
public void afterStep(io.cucumber.java.Scenario scenario) Step hooks invoked before and after a step.- Parameters:
scenario- the scenario
-
embedScreenshot
public void embedScreenshot(io.cucumber.java.Scenario scenario) After hooks run after the last step of each scenario, even when the step result is failed, undefined, pending, or skipped.- Parameters:
scenario- the scenario
-