net.thucydides.core.model
Class TestOutcome

Package class diagram package TestOutcome
java.lang.Object
  extended by net.thucydides.core.model.TestOutcome

public class TestOutcome
extends Object

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 scenario can be associated with a user story using the UserStory annotation. A TestOutcome is stored as an XML file after a test is executed. When the aggregate reports are generated, the test outcome XML files are loaded into memory and processed.

Author:
johnsmart

Nested Class Summary
static class TestOutcome.StepCountBuilder
           
 
Constructor Summary
protected TestOutcome(long startTime, long duration, String title, String description, String methodName, Class<?> testCase, List<TestStep> testSteps, List<String> issues, List<String> additionalIssues, Set<TestTag> tags, Story userStory, Throwable testFailureCause, TestResult annotatedResult, DataTable dataTable, com.google.common.base.Optional<String> qualifier, boolean manualTest)
           
  TestOutcome(String methodName)
          The title is immutable once set.
  TestOutcome(String methodName, Class<?> testCase)
           
protected TestOutcome(String methodName, Class<?> testCase, Story userStory)
          A test outcome should relate to a particular test class or user story class.
 
Method Summary
 void addFailingExternalStep(Throwable testFailureCause)
           
 void addFailingStepAsSibling(List<TestStep> testStepList, Throwable testFailureCause)
           
 void addIssues(List<String> issues)
           
 void addRow(DataTableRow dataTableRow)
           
 void addRow(Map<String,?> data)
           
 void addTags(List<TestTag> tags)
           
 TestOutcome addVersion(String version)
           
 TestOutcome addVersions(List<String> versions)
           
 TestOutcome asManualTest()
           
 void clearStartTime()
           
 int countNestedStepsWithResult(TestResult expectedResult, TestType testType)
           
 int countResults(TestResult expectedResult)
           
 int countResults(TestResult expectedResult, TestType expectedType)
           
 Integer countTestSteps()
           
 boolean dataIsPredefined()
           
 void endGroup()
          Finish the current group.
static TestOutcome forTest(String methodName, Class<?> testCase)
          Create a new test outcome instance for a given test class or user story.
static TestOutcome forTestInStory(String testName, Class<?> testCase, Story story)
           
static TestOutcome forTestInStory(String testName, Story story)
           
 String getCompleteName()
          Returns the name of the test prefixed by the name of the story.
 TestStep getCurrentGroup()
           
 TestStep getCurrentStep()
           
 String getDataDrivenSampleScenario()
           
 DataTable getDataTable()
           
 String getDescription()
           
 com.google.common.base.Optional<String> getDescriptionText()
          Tests may have a description.
 Long getDuration()
           
 double getDurationInSeconds()
           
 EnvironmentVariables getEnvironmentVariables()
           
 Integer getErrorCount()
           
 List<String> getExampleFields()
           
 Integer getFailureCount()
           
 ApplicationFeature getFeature()
          Get the feature that includes the user story tested by this test.
 List<TestStep> getFlattenedTestSteps()
           
 String getFormattedIssues()
           
 String getHtmlReport()
           
 Integer getIgnoredCount()
           
 int getImplementedTestCount()
           
 List<String> getIssueKeys()
           
 List<String> getIssues()
           
 TestStep getLastStep()
           
 List<TestStep> getLeafTestSteps()
           
 String getMethodName()
           
 Integer getNestedStepCount()
           
 double getOverallStability()
           
 String getPath()
           
 Integer getPendingCount()
           
 String getQualifiedMethodName()
           
 com.google.common.base.Optional<String> getQualifier()
           
 int getRecentFailCount()
           
 int getRecentPassCount()
           
 int getRecentPendingCount()
           
 double getRecentStability()
           
 Long getRecentTestRunCount()
           
 String getReportName()
           
 String getReportName(ReportType type)
           
 TestResult getResult()
          The outcome of the acceptance test, based on the outcome of the test steps.
 List<ScreenshotAndHtmlSource> getScreenshotAndHtmlSources()
           
 String getScreenshotReportName()
           
 List<Screenshot> getScreenshots()
           
 String getSessionId()
           
 String getSimpleReportName(ReportType type)
           
 Integer getSkippedCount()
           
 Integer getSkippedOrIgnoredCount()
           
 org.joda.time.DateTime getStartTime()
           
 TestStatistics getStatistics()
           
 Integer getStepCount()
           
 String getStoryTitle()
           
 Integer getSuccessCount()
           
 Set<TestTag> getTags()
           
 com.google.common.base.Optional<String> getTagValue(String tagType)
           
 Class<?> getTestCase()
           
 int getTestCount()
           
 Throwable getTestFailureCause()
           
 List<TestStep> getTestSteps()
          An acceptance test is made up of a series of steps.
 String getTitle()
          Return the human-readable name for this test.
 String getTitleWithLinks()
           
 Story getUserStory()
           
 List<String> getVersions()
           
 String getVideoLink()
          Returns the link to the associated video (e.g.
 boolean hasIssue(String issue)
           
 boolean hasNonStepFailure()
           
 boolean hasScreenshots()
           
 boolean hasTag(TestTag tag)
           
 boolean isDataDriven()
           
 Boolean isError()
           
 Boolean isFailure()
           
 boolean isManual()
           
 Boolean isPending()
           
 void isRelatedToIssue(String issue)
           
 Boolean isSkipped()
           
 boolean isStartTimeNotDefined()
           
 Boolean isSuccess()
           
 void lastStepFailedWith(StepFailure failure)
           
 void lastStepFailedWith(Throwable testFailureCause)
           
 void moveToNextRow()
           
 void recordDuration()
           
 TestOutcome recordStep(TestStep step)
          Add a test step to this acceptance test.
 TestOutcome recordSteps(List<TestStep> steps)
           
 void setAnnotatedResult(TestResult annotatedResult)
           
 void setDescription(String description)
           
 void setDuration(long duration)
           
 void setEnvironmentVariables(EnvironmentVariables environmentVariables)
           
 void setSessionId(String sessionId)
           
 void setStartTime(org.joda.time.DateTime startTime)
           
 void setStatistics(TestStatistics statistics)
           
 void setTags(Set<TestTag> tags)
           
 void setTestFailureCause(Throwable cause)
           
 void setTitle(String title)
           
 void setUserStory(Story story)
           
 void startGroup()
          Turns the current step into a group.
 void startGroup(String groupName)
          Deprecated. 
 String toString()
           
 boolean typeCompatibleWith(TestType testType)
           
 void updateCurrentRowResult(TestResult result)
           
 void useExamplesFrom(DataTable table)
           
 TestOutcome usingIssueTracking(IssueTracking issueTracking)
           
 TestOutcome withIssues(List<String> issues)
           
 TestOutcome withMethodName(String methodName)
           
 TestOutcome withQualifier(String qualifier)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TestOutcome

public TestOutcome(String methodName)
The title is immutable once set. For convenience, you can create a test run directly with a title using this constructor.

Parameters:
methodName - The name of the Java method that implements this test.

TestOutcome

public TestOutcome(String methodName,
                   Class<?> testCase)

TestOutcome

protected TestOutcome(String methodName,
                      Class<?> testCase,
                      Story userStory)
A test outcome should relate to a particular test class or user story class.

Parameters:
methodName - 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 test
userStory - 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(long startTime,
                      long duration,
                      String title,
                      String description,
                      String methodName,
                      Class<?> testCase,
                      List<TestStep> testSteps,
                      List<String> issues,
                      List<String> additionalIssues,
                      Set<TestTag> tags,
                      Story userStory,
                      Throwable testFailureCause,
                      TestResult annotatedResult,
                      DataTable dataTable,
                      com.google.common.base.Optional<String> qualifier,
                      boolean manualTest)
Method Detail

usingIssueTracking

public TestOutcome usingIssueTracking(IssueTracking issueTracking)

asManualTest

public TestOutcome asManualTest()

setEnvironmentVariables

public void setEnvironmentVariables(EnvironmentVariables environmentVariables)

getEnvironmentVariables

public EnvironmentVariables getEnvironmentVariables()

forTest

public static TestOutcome forTest(String methodName,
                                  Class<?> testCase)
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

public TestOutcome withQualifier(String qualifier)

withIssues

public TestOutcome withIssues(List<String> issues)

withMethodName

public TestOutcome withMethodName(String methodName)

getMethodName

public String getMethodName()
Returns:
The name of the Java method implementing this test, if the test is implemented in Java.

forTestInStory

public static TestOutcome forTestInStory(String testName,
                                         Story story)

forTestInStory

public static TestOutcome forTestInStory(String testName,
                                         Class<?> testCase,
                                         Story story)

toString

public String toString()
Overrides:
toString in class Object

getTitle

public String 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.

setDescription

public void setDescription(String description)

getDescription

public String getDescription()

getDescriptionText

public com.google.common.base.Optional<String> 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.


getTitleWithLinks

public String getTitleWithLinks()

getStoryTitle

public String getStoryTitle()

getPath

public String getPath()

getReportName

public String getReportName(ReportType type)

getSimpleReportName

public String getSimpleReportName(ReportType type)

getHtmlReport

public String getHtmlReport()

getReportName

public String getReportName()

getScreenshotReportName

public String getScreenshotReportName()

getTestSteps

public List<TestStep> 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.

hasScreenshots

public boolean hasScreenshots()

getScreenshotAndHtmlSources

public List<ScreenshotAndHtmlSource> getScreenshotAndHtmlSources()

getScreenshots

public List<Screenshot> getScreenshots()

hasNonStepFailure

public boolean hasNonStepFailure()

getFlattenedTestSteps

public List<TestStep> getFlattenedTestSteps()

getLeafTestSteps

public List<TestStep> getLeafTestSteps()

getResult

public TestResult 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

public TestOutcome recordSteps(List<TestStep> steps)

recordStep

public TestOutcome recordStep(TestStep step)
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

public ApplicationFeature 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

public void setTitle(String title)

startGroup

@Deprecated
public void startGroup(String groupName)
Deprecated. 

Creates a new step with this name and immediately turns it into a step group.


getQualifier

public com.google.common.base.Optional<String> 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.


getCurrentStep

public TestStep getCurrentStep()
Returns:
The current step is the last step in the step list, or the last step in the children of the current step group.

getLastStep

public TestStep getLastStep()

getCurrentGroup

public TestStep getCurrentGroup()

setUserStory

public void setUserStory(Story story)

setTestFailureCause

public void setTestFailureCause(Throwable cause)

getTestFailureCause

public Throwable getTestFailureCause()

setAnnotatedResult

public void setAnnotatedResult(TestResult annotatedResult)

getIssues

public List<String> getIssues()

getVersions

public List<String> getVersions()

getTestCase

public Class<?> getTestCase()

addVersion

public TestOutcome addVersion(String version)

addVersions

public TestOutcome addVersions(List<String> versions)

addIssues

public void addIssues(List<String> issues)

getFormattedIssues

public String getFormattedIssues()

isRelatedToIssue

public void isRelatedToIssue(String issue)

addFailingExternalStep

public void addFailingExternalStep(Throwable testFailureCause)

addFailingStepAsSibling

public void addFailingStepAsSibling(List<TestStep> testStepList,
                                    Throwable testFailureCause)

lastStepFailedWith

public void lastStepFailedWith(StepFailure failure)

lastStepFailedWith

public void lastStepFailedWith(Throwable testFailureCause)

getTags

public Set<TestTag> getTags()

setTags

public void setTags(Set<TestTag> tags)

addTags

public void addTags(List<TestTag> tags)

getIssueKeys

public List<String> getIssueKeys()

getQualifiedMethodName

public String getQualifiedMethodName()

getCompleteName

public String getCompleteName()
Returns the name of the test prefixed by the name of the story.


useExamplesFrom

public void useExamplesFrom(DataTable table)

moveToNextRow

public void moveToNextRow()

updateCurrentRowResult

public void updateCurrentRowResult(TestResult result)

dataIsPredefined

public boolean dataIsPredefined()

addRow

public void addRow(Map<String,?> data)

addRow

public void addRow(DataTableRow dataTableRow)

getTestCount

public int getTestCount()

getImplementedTestCount

public int getImplementedTestCount()

countResults

public int countResults(TestResult expectedResult)

countResults

public int countResults(TestResult expectedResult,
                        TestType expectedType)

typeCompatibleWith

public boolean typeCompatibleWith(TestType testType)

countNestedStepsWithResult

public int countNestedStepsWithResult(TestResult expectedResult,
                                      TestType testType)

getTagValue

public com.google.common.base.Optional<String> getTagValue(String tagType)

hasIssue

public boolean hasIssue(String issue)

hasTag

public boolean hasTag(TestTag tag)

setStartTime

public void setStartTime(org.joda.time.DateTime startTime)

clearStartTime

public void clearStartTime()

isManual

public boolean isManual()

isStartTimeNotDefined

public boolean isStartTimeNotDefined()

getStepCount

public Integer getStepCount()

getNestedStepCount

public Integer getNestedStepCount()

getSuccessCount

public Integer getSuccessCount()

getFailureCount

public Integer getFailureCount()

getErrorCount

public Integer getErrorCount()

getIgnoredCount

public Integer getIgnoredCount()

getSkippedOrIgnoredCount

public Integer getSkippedOrIgnoredCount()

getSkippedCount

public Integer getSkippedCount()

getPendingCount

public Integer getPendingCount()

isSuccess

public Boolean isSuccess()

isFailure

public Boolean isFailure()

isError

public Boolean isError()

isPending

public Boolean isPending()

isSkipped

public Boolean isSkipped()

getUserStory

public Story getUserStory()

recordDuration

public void recordDuration()

setDuration

public void setDuration(long duration)

getDuration

public Long getDuration()

getDurationInSeconds

public double getDurationInSeconds()
Returns:
The total duration of all of the tests in this set in milliseconds.

getVideoLink

public String getVideoLink()
Returns the link to the associated video (e.g. from Saucelabs) for this test.

Returns:
a URL.

getSessionId

public String getSessionId()

setSessionId

public void setSessionId(String sessionId)

countTestSteps

public Integer countTestSteps()

setStatistics

public void setStatistics(TestStatistics statistics)

getStatistics

public TestStatistics getStatistics()

getOverallStability

public double getOverallStability()

getRecentStability

public double getRecentStability()

getRecentTestRunCount

public Long getRecentTestRunCount()

getRecentPassCount

public int getRecentPassCount()

getRecentFailCount

public int getRecentFailCount()

getRecentPendingCount

public int getRecentPendingCount()

getStartTime

public org.joda.time.DateTime getStartTime()

isDataDriven

public boolean isDataDriven()

getExampleFields

public List<String> getExampleFields()

getDataDrivenSampleScenario

public String getDataDrivenSampleScenario()

getDataTable

public DataTable getDataTable()


Copyright © 2011-2013 Wakaleo Consulting. All Rights Reserved.