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 filesstatic org.openqa.selenium.WebDriverWeb driver instance (chrome, firefox, ...)protected TestScenarioLogCollectionLog collection for the current methodprotected TestFeaturePage object annotation referenceprotected TestFeatureLogCollectionLog collection for all methods in this classstatic final TestSuiteLogCollectionGlobal log collection that holds all log messages from the tests -
Constructor Summary
ConstructorsConstructorDescriptionConstructor with initializationQtafTestNGCucumberContext(boolean shallInitialize) Constructor with optional initialization -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd logger to all instance fieldsvoidafterStep(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.createAndSetNewLogCollection(int hashCode, String methodId, String testId) Create a new method log collection and set it as the current log collectionvoidembedScreenshot(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 skippedGet current log collectionInitialize test contextvoidinitializeTest(io.cucumber.java.Scenario scenario) Before hooks run before the first step of each scenario.protected voidonBeforeScenario(QTAFCucumberScenarioEntity scenarioEntity) Method that runs before each scenariovoidRestart browservoidrunScenario(io.cucumber.testng.PickleWrapper pickleWrapper, io.cucumber.testng.FeatureWrapper featureWrapper) TestNG test that executes all cucumber scenariosObject[][]Method that loads and provides Cucumber Scenario entitiessetLogCollection(TestScenarioLogCollection collection) Set the current log collectionbooleanshallRun(QTAFCucumberScenarioEntity scenarioEntity) Method that check if a scenario shall run or notMethods 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()Restart browser- Specified by:
restartDriverin interfaceIQtafTestContext
-
initialize
Initialize test context- Specified by:
initializein interfaceIQtafTestContext
-
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
-
createAndSetNewLogCollection
public TestScenarioLogCollection createAndSetNewLogCollection(int hashCode, String methodId, String testId) Description copied from interface:IQtafTestContextCreate a new method log collection and set it as the current log collection- Specified by:
createAndSetNewLogCollectionin interfaceIQtafTestContext- Parameters:
hashCode- Unique test hash codemethodId- test methodtestId- test class- Returns:
- collection
-
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. -
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. -
afterStep
public void afterStep(io.cucumber.java.Scenario scenario) Step hooks invoked before and after a step. -
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-
-