Class TestScenarioLogCollection
java.lang.Object
de.qytera.qtaf.core.log.model.collection.TestScenarioLogCollection
This class works as a collection for log messages that are produced during a test execution.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumTest execution status.static classData class for step parameter information. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLogMessage(LogLevel level, String message) Add log message.voidaddLogMessage(LogMessage logMessage) Add log message object.voidaddParameters(Object[] parameterValues) Add test parameters to log.addParameters(Parameter[] parameters, Object[] values) Add test parameters to log.voidaddScreenshotPath(String filepath) Add screenshot path to test scenario log.Add tag to test scenario log.static StringBuild ID.static voidRemove all scenario log collections.voidMethod to compute the status of the test scenario.static TestScenarioLogCollectioncreateTestScenarioLogCollection(String featureId, String abstractScenarioId, String instanceId, String scenarioName) Factory method.Add debug message.booleanOverride equals to compare two TestScenarioLogCollection objects.Add error message.static booleanexists(TestScenarioLogCollection scenarioLogCollection) Check if index already has this ScenarioLogCollection.static TestScenarioLogCollectionfromQtafTestEventPayload(IQtafTestEventPayload iQtafTestEventPayload) Factory method.Get abstractScenarioId.<T> TgetAnnotation(Class<T> annotationClass) Get a specific annotation of this scenario.Get annotations.Get description.longGet duration.getEnd()Get end.Get uniqueId.String[]Get groupDependencies.String[]Get groups.static intCount the number of scenario log collections saved in the index.Get instanceId.Get logMessages.<T extends LogMessage>
List<T>getLogMessages(Class<T> logMessageClass) Returns all log message of the provided class, filtering out log messages that do not match the class.String[]Get methodDependencies.Get test ID.Get testId.Get screenshotAfter.Get screenshotBefore.Get screenshotPaths.getStart()Get start.Get status.Get the log message object of the step that is currently pending.getTags()Get tags.Get testParameters.longGet threadId.Get threadName.inthashCode()Calculate hash code for this instance.Add info message.setAbstractScenarioId(String abstractScenarioId) Set abstractScenarioId.setAnnotations(Annotation[] annotations) Set annotations.setDescription(String description) Set test description.setDuration(long duration) Set duration.Set end.setGroupDependencies(String[] groupDependencies) Set test group dependencies.Set groups.setInstanceId(String instanceId) Set instanceId.voidsetMethodDependencies(String[] methodDependencies) Set test method dependencies.voidsetScreenshotAfter(String screenshotAfter) Set screenshotAfter.voidsetScreenshotBefore(String screenshotBefore) Set screenshotBefore.Set start.Sets the test status.setThreadId(long threadId) Set threadId.setThreadName(String threadName) Set threadName.Add warn message.
-
Method Details
-
createTestScenarioLogCollection
public static TestScenarioLogCollection createTestScenarioLogCollection(String featureId, String abstractScenarioId, String instanceId, String scenarioName) Factory method.Creates new test log collection.
If a collection with the given ID exists then return the existing collection. This method has to be synchronized so that it works correctly when using multiple threads.- Parameters:
featureId- Unique collection IDabstractScenarioId- Method ID (packageName + className + methodName)instanceId- Test object IDscenarioName- Test ID- Returns:
- test log collection
-
fromQtafTestEventPayload
public static TestScenarioLogCollection fromQtafTestEventPayload(IQtafTestEventPayload iQtafTestEventPayload) Factory method.Factory method that creates new log collection from test event payload.
This method has to be synchronized so that it works correctly when using multiple threads.- Parameters:
iQtafTestEventPayload- test event payload- Returns:
- test log collection
-
equals
Override equals to compare two TestScenarioLogCollection objects. -
hashCode
public int hashCode()Calculate hash code for this instance. The contains() methods of the collections use the hash code to check if object is already stored. -
getFeatureId
Get uniqueId.- Returns:
- uniqueId
-
buildId
Build ID.- Parameters:
abstractScenarioId- Method IDinstanceId- Test ID- Returns:
- ID
-
getScenarioId
Get test ID.- Returns:
- test ID
-
getScenarioName
Get testId.- Returns:
- testId Test Id
-
getAbstractScenarioId
Get abstractScenarioId.- Returns:
- abstractScenarioId
-
setAbstractScenarioId
Set abstractScenarioId.- Parameters:
abstractScenarioId- AbstractScenarioId- Returns:
- this
-
getInstanceId
Get instanceId.- Returns:
- instanceId
-
setInstanceId
Set instanceId.- Parameters:
instanceId- InstanceId- Returns:
- this
-
getStatus
Get status.- Returns:
- status Status
-
computeStatus
public void computeStatus()Method to compute the status of the test scenario. -
setStatus
Sets the test status.- Parameters:
status- test status- Returns:
- this
-
setDescription
Set test description.- Parameters:
description- test description- Returns:
- this
-
setGroupDependencies
Set test group dependencies.- Parameters:
groupDependencies- test group dependencies- Returns:
- this
-
setMethodDependencies
Set test method dependencies.- Parameters:
methodDependencies- test method dependencies
-
getTestParameters
Get testParameters.- Returns:
- testParameters
-
addParameters
Add test parameters to log.- Parameters:
parameters- method parametersvalues- method values- Returns:
- this
-
addParameters
Add test parameters to log.- Parameters:
parameterValues- method values
-
getAnnotations
Get annotations.- Returns:
- annotations
-
getAnnotation
Get a specific annotation of this scenario. Always returns the first annotation found in case there are more than one.- Type Parameters:
T- the annotation's type- Parameters:
annotationClass- the class of the annotation to retrieve- Returns:
- the annotation if it exists or null
-
setAnnotations
Set annotations.- Parameters:
annotations- Annotations- Returns:
- this
-
getLogMessages
Get logMessages.- Returns:
- logMessages LogMessages
-
getLogMessages
Returns all log message of the provided class, filtering out log messages that do not match the class.- Type Parameters:
T- any class extending theLogMessageclass- Parameters:
logMessageClass- the desired log messages' class- Returns:
- a list of log messages with type
T
-
getStepLogOfPendingStep
Get the log message object of the step that is currently pending.- Returns:
- Step log object of the currently pending step
-
addLogMessage
Add log message object. This method needs to run synchronized because of the check for existence.- Parameters:
logMessage- log message object
-
addLogMessage
Add log message.- Parameters:
level- log levelmessage- log message
-
getScreenshotPaths
Get screenshotPaths.- Returns:
- screenshotPaths
-
addScreenshotPath
Add screenshot path to test scenario log.- Parameters:
filepath- Path to screenshot file
-
getScreenshotBefore
Get screenshotBefore.- Returns:
- screenshotBefore
-
setScreenshotBefore
Set screenshotBefore.- Parameters:
screenshotBefore- ScreenshotBefore
-
getScreenshotAfter
Get screenshotAfter.- Returns:
- screenshotAfter
-
setScreenshotAfter
Set screenshotAfter.- Parameters:
screenshotAfter- ScreenshotAfter
-
getTags
Get tags.- Returns:
- tags
-
addTag
Add tag to test scenario log.- Parameters:
key- Tag keyvalue- Tag value- Returns:
- this
-
debug
Add debug message.- Parameters:
message- message- Returns:
- this
-
info
Add info message.- Parameters:
message- message- Returns:
- this
-
warn
Add warn message.- Parameters:
message- message- Returns:
- this
-
error
Add error message.- Parameters:
message- message- Returns:
- this
-
getDescription
Get description.- Returns:
- description
-
getGroupDependencies
Get groupDependencies.- Returns:
- groupDependencies
-
getMethodDependencies
Get methodDependencies.- Returns:
- methodDependencies
-
getStart
Get start.- Returns:
- start
-
setStart
Set start.- Parameters:
start- Start- Returns:
- this
-
getEnd
Get end.- Returns:
- end
-
setEnd
Set end.- Parameters:
end- End- Returns:
- this
-
getThreadId
public long getThreadId()Get threadId.- Returns:
- threadId
-
setThreadId
Set threadId.- Parameters:
threadId- ThreadId- Returns:
- this
-
getThreadName
Get threadName.- Returns:
- threadName
-
setThreadName
Set threadName.- Parameters:
threadName- ThreadName- Returns:
- this
-
getGroups
Get groups.- Returns:
- groups
-
setGroups
Set groups.- Parameters:
groups- Groups- Returns:
- this
-
getDuration
public long getDuration()Get duration.- Returns:
- duration
-
setDuration
Set duration.- Parameters:
duration- Duration- Returns:
- this
-
exists
Check if index already has this ScenarioLogCollection.- Parameters:
scenarioLogCollection- Scenario log collection- Returns:
- true if exists, false otherwise
-
getIndexSize
public static int getIndexSize()Count the number of scenario log collections saved in the index.- Returns:
- number of scenario log collections saved in the index
-
clearIndex
public static void clearIndex()Remove all scenario log collections.
-