java.lang.Object
net.thucydides.model.domain.TestOutcome
Represents the results of a test (or "scenario") execution. This
includes the narrative steps taken during the test, screenshots at each step,
the results of each step, and the overall result. A test getscenario
can be associated with a user story using the UserStory annotation.
A TestOutcome is stored after a test is executed. When the aggregate reports are generated, the test outcome files are loaded into memory and processed.
- Author:
- johnsmart
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classclass -
Constructor Summary
ConstructorsModifierConstructorDescriptionTestOutcome(String name) The title is immutable once set.TestOutcome(String name, Class<?> testCase) TestOutcome(String name, Class<?> testCase, String context, EnvironmentVariables environmentVariables) protectedTestOutcome(String name, Class<?> testCase, Story userStory) protectedTestOutcome(String name, Class<?> testCase, Story userStory, EnvironmentVariables environmentVariables) A test outcome should relate to a particular test class or user story class.TestOutcome(String name, Class<?> testCase, EnvironmentVariables environmentVariables) Create a test outcome based on a test method in a test class.protectedTestOutcome(ZonedDateTime startTime, long duration, String title, String description, String name, String id, String scenarioId, String methodName, Class<?> testCase, List<TestStep> testSteps, List<String> issues, List<String> additionalIssues, List<CastMember> actors, Set<TestTag> tags, TestTag featureTag, Story userStory, FailureCause testFailureCause, String testFailureClassname, String testFailureMessage, String testFailureSummary, TestResult annotatedResult, DataTable dataTable, Optional<String> qualifier, String driver, boolean manualTest, boolean isManualTestingUpToDate, String lastTested, List<String> testEvidence, String projectKey, EnvironmentVariables environmentVariables, ExternalLink externalLink, String context, String testSource) protectedTestOutcome(ZonedDateTime startTime, String name, Class<?> testCase, Story userStory, EnvironmentVariables environmentVariables) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDataFrom(DataTable newDataTable) voidaddFailingStepAsSibling(List<TestStep> testStepList, Throwable testFailureCause) voidvoidaddNewExamplesFrom(DataTable table) voidvoidaddRow(DataTableRow dataTableRow) voidvoidvoidaddUserStoryFeatureTo(Set<TestTag> augmentedTags) addVersion(String version) addVersions(List<String> versions) voidappendTestFailure(TestFailureCause failureCause) voidassignAbility(String name, String ability) voidassignDescriptionToActor(String name, String description) voidassignFact(String name, String fact) voidFix the values of synthetic fields for serialization purposesvoidvoidvoidbooleancontainsAtLeastOneOutcomeWithResult(TestResult expectedResult) copy()intcountNestedStepsWithResult(TestResult expectedResult, TestType testType) intcountResults(TestResult expectedResult) intcountResults(TestResult expectedResult, TestType expectedType) booleanvoidvoidendGroup()Finish the current group.booleanforProject(String project) static TestOutcomeCreate a new test outcome instance for a given test class or user story.static TestOutcomeforTestInStory(String testName, Class<?> testCase, Story story) static TestOutcomeforTestInStory(String testName, Story story) fromStep(int index) Returns the name of the test prefixed by the name of the story.intTests may have a description.doubleGet the feature that includes the user story tested by this test.getFlags()getId()intgetName()getOrder()getPath()getReportName(ReportType type) The outcome of the acceptance test, based on the outcome of the test steps.longgetRule()getStepResult(int stepNumber) Find the first and last screenshots for each aggregate step, and every screenshots for leaf steps.getTags()getTagValue(String tagType) Class<?> intintAn acceptance test is made up of a series of steps.getTimestamp(DateTimeFormatter formater) getTitle()Return the human-readable name for this test.getTitle(boolean qualified) Returns the link to the associated video (e.g.has()booleanhasAMoreGeneralFormOfTag(TestTag specificTag) booleanhasAMoreSpecificFormOfTag(TestTag generalTag) booleaninthashCode()booleanbooleanbooleanbooleanbooleanhasResult(TestResult result) booleanbooleanbooleanhasTagWithName(String tagName) booleanhasTagWithType(String tagType) booleanhasTagWithTypes(List<String> tagTypes) static net.thucydides.model.domain.TestOutcome.TestOutcomeWithEnvironmentBuilderinEnvironment(EnvironmentVariables environmentVariables) inTestRunTimestamped(ZonedDateTime testRunTimestamp) booleanbooleanisError()booleanisManual()booleanvoidisRelatedToIssue(String issue) booleanbooleanbooleanlastStep()voidlastStepFailedWith(Throwable testFailureCause) voidlastStepFailedWith(StepFailure failure) voidmergeMostRecentSteps(int maxStepsToMerge) voidvoidoverrideAnnotatedResult(TestResult annotatedResult) voidoverrideResult(TestResult result) recordChildSteps(List<TestStep> steps) voidvoidrecordDuration(ZonedDateTime finishTime) recordStep(TestStep step) Add a test step to this acceptance test.recordSteps(List<TestStep> steps) removeTopLevelStepsNotMatching(Predicate<TestStep> condition) voidresetFailingStepsCausedBy(Class<? extends Throwable> expected) voidsetAllStepsTo(TestResult result) voidsetAnnotatedResult(TestResult annotatedResult) voidsetBackgroundDescription(String description) voidsetBackgroundTitle(String title) voidsetContext(String context) Setting the contextvoidsetDescription(String description) voidvoidsetDuration(long duration) voidsetEnvironmentVariables(EnvironmentVariables environmentVariables) voidsetFlakyTestFailureCause(TestFailureCause flakyTestFailureCause) voidsetLastTested(String lastTested) voidsetLink(ExternalLink externalLink) voidsetManualTestEvidence(List<String> manualTestEvidence) voidsetManualTestingUpToDate(Boolean upToDate) voidsetOrder(int order) voidsetResult(TestResult annotatedResult) voidvoidsetSessionId(String sessionId) voidsetStartTime(ZonedDateTime startTime) voidvoidsetTestFailureMessage(String testFailureMessage) voidsetTestRunTimestamp(ZonedDateTime testRunTimestamp) voidsetTestSource(String testSource) voidvoidsetUserStory(Story story) voidTurns the current step into a group.voidstartGroup(String groupName) Deprecated.voidtestFailedWith(Throwable cause) testStepWithDescription(String expectedDescription) toJson()toString()booleantypeCompatibleWith(TestType testType) voidupdateCurrentRowResult(TestResult result) voidupdateDataTableResult(int row, TestResult result) voidvoidvoiduseExamplesFrom(DataTable table) voiduseScenarioOutline(String scenarioOutline) usingIssueTracking(IssueTracking issueTracking) withDataRowsfilteredbyTagsFrom(Collection<TestTag> filterTags) withExamplesHavingResult(TestResult result) withExamplesMatching(Predicate<TestStep> condition) protected TestOutcomewithFlagProvider(FlagProvider flagProvider) Set the current flag provider; only used for testing purposes.withIssues(List<String> issues) withQualifier(String qualifier) withResult(TestResult annotatedResult) withScenarioId(String scenarioId) withStartTime(ZonedDateTime startTime) withTestMethodName(String methodName) withTestSource(String testSource)
-
Constructor Details
-
TestOutcome
The title is immutable once set. For convenience, you can create a test run directly with a title using this constructor.- Parameters:
name- The name of the Java method that implements this test.
-
TestOutcome
-
TestOutcome
Create a test outcome based on a test method in a test class. The requirement type will be derived if possible using the class package.- Parameters:
name-testCase-
-
TestOutcome
public TestOutcome(String name, Class<?> testCase, String context, EnvironmentVariables environmentVariables) -
TestOutcome
-
TestOutcome
protected TestOutcome(String name, Class<?> testCase, Story userStory, EnvironmentVariables environmentVariables) A test outcome should relate to a particular test class or user story class.- Parameters:
name- The name of the Java method implementing this test, if the test is a JUnit or TestNG test (for example)testCase- The test class that contains this test method, if the test is a JUnit or TestNG testuserStory- If the test is not implemented by a Java class (e.g. an easyb story), we may just use the Story class to represent the story in which the test is implemented.
-
TestOutcome
protected TestOutcome(ZonedDateTime startTime, String name, Class<?> testCase, Story userStory, EnvironmentVariables environmentVariables) -
TestOutcome
protected TestOutcome(ZonedDateTime startTime, long duration, String title, String description, String name, String id, String scenarioId, String methodName, Class<?> testCase, List<TestStep> testSteps, List<String> issues, List<String> additionalIssues, List<CastMember> actors, Set<TestTag> tags, TestTag featureTag, Story userStory, FailureCause testFailureCause, String testFailureClassname, String testFailureMessage, String testFailureSummary, TestResult annotatedResult, DataTable dataTable, Optional<String> qualifier, String driver, boolean manualTest, boolean isManualTestingUpToDate, String lastTested, List<String> testEvidence, String projectKey, EnvironmentVariables environmentVariables, ExternalLink externalLink, String context, String testSource)
-
-
Method Details
-
inEnvironment
public static net.thucydides.model.domain.TestOutcome.TestOutcomeWithEnvironmentBuilder inEnvironment(EnvironmentVariables environmentVariables) -
calculateDynamicFieldValues
public void calculateDynamicFieldValues()Fix the values of synthetic fields for serialization purposes -
usingIssueTracking
-
setToManual
-
withTestSource
-
withFlagProvider
Set the current flag provider; only used for testing purposes. -
setEnvironmentVariables
-
getEnvironmentVariables
-
copy
-
forTest
Create a new test outcome instance for a given test class or user story.- Parameters:
methodName- The name of the Java method implementing this test,testCase- The JUnit or TestNG test class that contains this test method- Returns:
- A new TestOutcome object for this test.
-
withQualifier
-
withIssues
-
withTags
-
withStartTime
-
getName
- Returns:
- The name of the Java method implementing this test, if the test is implemented in Java.
-
forTestInStory
-
forTestInStory
-
toString
-
getTitle
Return the human-readable name for this test. This is derived from the test name for tests using a Java implementation, or can also be defined using the Title annotation.- Returns:
- the human-readable name for this test.
-
getTitle
-
getUnqualified
-
getQualified
-
setAllStepsTo
-
addDataFrom
-
clearForcedResult
public void clearForcedResult() -
setDriver
-
getDriver
-
getBrowser
-
resetFailingStepsCausedBy
-
replace
-
mergeMostRecentSteps
public void mergeMostRecentSteps(int maxStepsToMerge) -
updateOverallResults
public void updateOverallResults() -
getFailingStep
-
getId
-
getScenarioId
-
getParentId
-
withId
-
withScenarioId
-
updateTopLevelStepResultsTo
-
getTestFailureSummary
-
getFlakyTestFailureCause
-
setFlakyTestFailureCause
-
hasTagWithName
-
hasTagWithType
-
hasTagWithTypes
-
getDataTableRowCount
public int getDataTableRowCount() -
getTestStepCount
public int getTestStepCount() -
castActor
-
assignFact
-
assignAbility
-
assignDescriptionToActor
-
setManualTestEvidence
-
getManualTestEvidence
-
getRenderedManualTestEvidence
-
setLink
-
hasNoSteps
public boolean hasNoSteps() -
withSteps
-
isUnsuccessful
public boolean isUnsuccessful() -
isAJUnit5Test
public boolean isAJUnit5Test() -
updateDataTableResult
-
withTestMethodName
-
getStepResult
-
isTitleWithIssues
public boolean isTitleWithIssues() -
setDescription
-
setBackgroundDescription
-
setBackgroundTitle
-
getDescription
-
getBackgroundDescription
-
getBackgroundTitle
-
getDescriptionText
Tests may have a description. This can be defined with the scenarios (e.g. in the .feature files for Cucumber) or defined elsewhere, such as in JIRA for manual tests. -
toJson
-
getTitleWithLinks
-
getStoryTitle
-
getPath
-
getPathId
-
getReportName
-
getSimpleReportName
-
getHtmlReport
-
getReportName
-
getScreenshotReportName
-
getTestSteps
An acceptance test is made up of a series of steps. Each step is in fact a small test, which follows on from the previous one. The outcome of the acceptance test as a whole depends on the outcome of all of the steps.- Returns:
- A list of top-level test steps for this test.
-
getLatestTopLevelTestStep
-
hasScreenshots
public boolean hasScreenshots() -
hasRestQueries
public boolean hasRestQueries() -
getScreenshotAndHtmlSources
-
getScreenshots
-
getStepScreenshots
Find the first and last screenshots for each aggregate step, and every screenshots for leaf steps. -
hasNonStepFailure
public boolean hasNonStepFailure() -
getFlattenedTestSteps
-
getLeafTestSteps
-
getResult
The outcome of the acceptance test, based on the outcome of the test steps. If any steps fail, the test as a whole is considered a failure. If any steps are pending, the test as a whole is considered pending. If all of the steps are ignored, the test will be considered 'ignored'. If all of the tests succeed except the ignored tests, the test is a success. The test result can also be overridden using the 'setResult()' method.- Returns:
- The outcome of this test.
-
recordSteps
-
recordChildSteps
-
recordStep
Add a test step to this acceptance test.- Parameters:
step- a completed step to be added to this test outcome.- Returns:
- this TestOucome insstance - this is a convenience to allow method chaining.
-
getFeature
Get the feature that includes the user story tested by this test. If no user story is defined, no feature can be returned, so the method returns null. If a user story has been defined without a class (for example, one that has been reloaded), the feature will be built using the feature name and id in the user story.- Returns:
- The Feature defined for this TestOutcome, if any
-
setTitle
-
startGroup
Deprecated.Creates a new step with this name and immediately turns it into a step group. -
getQualifier
-
startGroup
public void startGroup()Turns the current step into a group. Subsequent steps will be added as children of the current step. -
endGroup
public void endGroup()Finish the current group. Subsequent steps will be added after the current step. -
currentStep
- Returns:
- The current step is the last step in the step list, or the last step in the children of the current step group.
-
lastStep
-
currentGroup
-
setUserStory
-
determineTestFailureCause
-
appendTestFailure
-
testStepWithDescription
-
getTestFailureCause
-
getTestFailureErrorType
-
getNestedTestFailureCause
-
firstStepWithErrorMessage
-
testFailureMessage
-
getErrorMessage
-
getConciseErrorMessage
-
setTestFailureMessage
-
getTestFailureMessage
-
getTestFailureClassname
-
setAnnotatedResult
-
overrideAnnotatedResult
-
setResult
-
overrideResult
-
withResult
-
getAnnotatedResult
-
getAdditionalVersions
-
getAdditionalIssues
-
getIssues
-
getVersions
-
getTestCase
-
getTestCaseName
-
getMethodName
-
addVersion
-
addVersions
-
forProject
-
getRule
-
setRule
-
getProject
-
inTestRunTimestamped
-
setTestRunTimestamp
-
addIssues
-
getFormattedIssues
-
isRelatedToIssue
-
addFailingStepAsSibling
-
lastStepFailedWith
-
lastStepFailedWith
-
testFailedWith
-
getTags
-
getAllTags
-
addUserStoryFeatureTo
-
setTags
-
addTags
-
addTag
-
getIssueKeys
-
getQualifiedMethodName
-
getQualifiedId
-
getNonNullContext
-
getContext
-
setContext
Setting the context- Parameters:
context-
-
getCompleteName
Returns the name of the test prefixed by the name of the story. -
useExamplesFrom
-
addNewExamplesFrom
-
moveToNextRow
public void moveToNextRow() -
updateCurrentRowResult
-
dataIsPredefined
public boolean dataIsPredefined() -
addRow
-
addRow
-
getTestCount
public int getTestCount() -
getImplementedTestCount
public int getImplementedTestCount() -
countResults
-
countResults
-
typeCompatibleWith
-
countNestedStepsWithResult
-
getTagValue
-
hasIssue
-
hasTag
-
hasAMoreGeneralFormOfTag
-
hasAMoreSpecificFormOfTag
-
setStartTime
-
clearStartTime
public void clearStartTime() -
isManual
public boolean isManual() -
getLastTested
-
setLastTested
-
isManualTestingUpToDate
public boolean isManualTestingUpToDate() -
setManualTestingUpToDate
-
getFlags
-
isStartTimeNotDefined
public boolean isStartTimeNotDefined() -
has
-
getStepCount
-
getRunningStepCount
-
getNestedStepCount
-
getSuccessCount
-
getFailureCount
-
getErrorCount
-
getCompromisedCount
-
getIgnoredCount
-
getSkippedOrIgnoredCount
-
getSkippedCount
-
getPendingCount
-
isSuccess
-
isFailure
-
isCompromised
-
isError
-
isPending
-
isSkipped
-
getUserStory
-
recordDuration
public void recordDuration() -
recordDuration
-
setDuration
public void setDuration(long duration) -
getDuration
-
getEndTime
-
getDurationInSeconds
public double getDurationInSeconds()- Returns:
- The total duration of all of the tests in this set in milliseconds.
-
getVideoLink
Returns the link to the associated video (e.g. from Saucelabs) for this test.- Returns:
- a URL.
-
getSessionId
-
setSessionId
-
countTestSteps
-
getStartTime
-
getStartedAt
-
getTimestamp
-
getTimestamp
-
isDataDriven
public boolean isDataDriven() -
getExampleFields
-
useScenarioOutline
-
getDataDrivenSampleScenario
-
getDataTable
-
equals
-
hashCode
public int hashCode() -
getFeatureTag
-
getFailureDetails
-
getTestSource
-
setTestSource
-
getActors
-
hasEvidence
public boolean hasEvidence() -
getEvidence
-
withDataRowsfilteredbyTag
-
withDataRowsfilteredbyTagsFrom
-
getExternalLink
-
setOrder
public void setOrder(int order) -
getOrder
-
fromStep
-
fromStep
-
withExamplesMatching
-
withExamplesHavingResult
-
asTestCases
-
getTestData
-
removeTopLevelStepsNotMatching
-
removeTopLevelStepsNotHavingResult
-
containsAtLeastOneOutcomeWithResult
-
getAllResultsStream
-
getAllResults
-
getResultCount
public long getResultCount() -
getDistinctResults
-
hasResult
-