Class TestCaseState

java.lang.Object
io.cucumber.core.runner.TestCaseState
All Implemented Interfaces:
TestCaseState

class TestCaseState extends Object implements TestCaseState
  • Field Details

    • stepResults

      private final List<Result> stepResults
    • bus

      private final EventBus bus
    • testCase

      private final TestCase testCase
    • testExecutionId

      private final UUID testExecutionId
    • currentTestStepId

      private @Nullable UUID currentTestStepId
    • currentPickleStep

      private @Nullable Step currentPickleStep
  • Constructor Details

  • Method Details

    • add

      void add(Result result)
    • getTestExecutionId

      UUID getTestExecutionId()
    • getSourceTagNames

      public Collection<String> getSourceTagNames()
      Description copied from interface: TestCaseState
      Return tags of this scenario.
      Specified by:
      getSourceTagNames in interface TestCaseState
      Returns:
      tags of this scenario.
    • getStatus

      public Status getStatus()
      Description copied from interface: TestCaseState
      Returns the current status of this test case.

      The test case status is calculated as the most severe status of the executed steps in the testcase so far.

      Specified by:
      getStatus in interface TestCaseState
      Returns:
      the current status of this test case
    • isFailed

      public boolean isFailed()
      Description copied from interface: TestCaseState
      Returns true when the scenario has failed.

      This is implemented as this.getStatus() == Status.FAILED.

      Specified by:
      isFailed in interface TestCaseState
      Returns:
      true if the scenario has failed.
    • attach

      public void attach(byte[] data, String mediaType, @Nullable String name)
      Description copied from interface: TestCaseState
      Attach data to the report(s).
       
       // Attach a screenshot. See your UI automation tool's docs for
       // details about how to take a screenshot.
       scenario.attach(pngBytes, "image/png", "Bartholomew and the Bytes of the Oobleck");
       
       

      To ensure reporting tools can understand what the data is a mediaType must be provided. For example: text/plain, image/png, text/html;charset=utf-8.

      Media types are defined in RFC 7231 Section 3.1.1.1.

      Specified by:
      attach in interface TestCaseState
      Parameters:
      data - what to attach, for example an image.
      mediaType - what is the data?
      name - attachment name
    • attach

      public void attach(String data, String mediaType, @Nullable String name)
      Description copied from interface: TestCaseState
      Attach data to the report(s).
      Specified by:
      attach in interface TestCaseState
      Parameters:
      data - what to attach, for example html.
      mediaType - what is the data?
      name - attachment name
      See Also:
    • log

      public void log(String text)
      Description copied from interface: TestCaseState
      Outputs some text into the report.
      Specified by:
      log in interface TestCaseState
      Parameters:
      text - what to put in the report.
      See Also:
    • getName

      public String getName()
      Description copied from interface: TestCaseState
      Returns the name of the Scenario
      Specified by:
      getName in interface TestCaseState
      Returns:
      the name of the Scenario
    • getId

      public String getId()
      Description copied from interface: TestCaseState
      Returns the id of the Scenario.
      Specified by:
      getId in interface TestCaseState
      Returns:
      the id of the Scenario.
    • getUri

      public URI getUri()
      Description copied from interface: TestCaseState
      Returns the uri of the Scenario.
      Specified by:
      getUri in interface TestCaseState
      Returns:
      the uri of the Scenario.
    • getLanguage

      public String getLanguage()
      Description copied from interface: TestCaseState
      Returns the language of the Scenario.
      Specified by:
      getLanguage in interface TestCaseState
      Returns:
      the language of the Scenario.
    • getLine

      public Integer getLine()
      Description copied from interface: TestCaseState
      Returns the line in the feature file of the Scenario.

      If this is a Scenario from Scenario Outlines this will return the line of the example row in the Scenario Outline.

      Specified by:
      getLine in interface TestCaseState
      Returns:
      the line in the feature file of the Scenario.
    • geCurrentPickleStep

      public Optional<Step> geCurrentPickleStep()
      Specified by:
      geCurrentPickleStep in interface TestCaseState
    • getError

      @Nullable Throwable getError()
    • setCurrentTestStepId

      void setCurrentTestStepId(UUID currentTestStepId)
    • clearCurrentTestStepId

      void clearCurrentTestStepId()
    • setCurrentPickleStep

      void setCurrentPickleStep(Step currentPickleStep)
    • clearCurrentPickleStep

      void clearCurrentPickleStep()
    • getRequiredCurrentTestStepId

      private UUID getRequiredCurrentTestStepId()