Package de.qytera.qtaf.testng.context
Class QtafTestNGContext
java.lang.Object
de.qytera.qtaf.testng.context.QtafTestNGContext
- All Implemented Interfaces:
IQtafTestContext
- Direct Known Subclasses:
QtafCucumberHooks
@Guice(modules=QtafModule.class)
public abstract class QtafTestNGContext
extends Object
implements IQtafTestContext
Test context works as a factory class and state manager for test classes.
It provides information about the current test class like information about
annotations and holds objects needed during test executing (i.e. loggers, etc).
-
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd logger to all instance fieldscreateAndSetNewLogCollection(int hashCode, String methodId, String testId) Create a new method log collection and set it as the current log collectionGet current log collectionInitialize test contextvoidRestart browsersetLogCollection(TestScenarioLogCollection collection) Set the current log collection
-
Field Details
-
config
Holds values from JSON configuration files -
driver
public static org.openqa.selenium.WebDriver driverWeb driver instance (chrome, firefox, ...) -
testSuiteLogCollection
Global log collection that holds all log messages from the tests -
testFeatureAnnotation
Page object annotation reference -
testFeatureLogCollection
Log collection for all methods in this class -
logCollection
Log collection for the current method
-
-
Constructor Details
-
QtafTestNGContext
public QtafTestNGContext()Constructor
-
-
Method Details
-
initialize
Initialize test context- Specified by:
initializein interfaceIQtafTestContext
-
restartDriver
public void restartDriver()Restart browser- Specified by:
restartDriverin interfaceIQtafTestContext
-
getLogCollection
Get current log collection- Specified by:
getLogCollectionin interfaceIQtafTestContext- Returns:
- log collection
-
createAndSetNewLogCollection
public TestScenarioLogCollection createAndSetNewLogCollection(int hashCode, String methodId, String testId) Create 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
-
setLogCollection
Set the current log collection- Specified by:
setLogCollectionin interfaceIQtafTestContext- Parameters:
collection- log collection- Returns:
- this
-
addLoggerToFieldsRecursively
public void addLoggerToFieldsRecursively()Add logger to all instance fields- Specified by:
addLoggerToFieldsRecursivelyin interfaceIQtafTestContext
-