Class AllureLifecycle

java.lang.Object
io.qameta.allure.AllureLifecycle

public class AllureLifecycle extends Object
The class contains Allure context and methods to change it.
  • Constructor Details

  • Method Details

    • startTestContainer

      public void startTestContainer(String containerUuid, io.qameta.allure.model.TestResultContainer container)
      Starts test container with specified parent container.
      Parameters:
      containerUuid - the uuid of parent container.
      container - the container.
    • startTestContainer

      public void startTestContainer(io.qameta.allure.model.TestResultContainer container)
      Starts test container.
      Parameters:
      container - the container.
    • updateTestContainer

      public void updateTestContainer(String uuid, Consumer<io.qameta.allure.model.TestResultContainer> update)
      Updates test container.
      Parameters:
      uuid - the uuid of container.
      update - the update function.
    • stopTestContainer

      public void stopTestContainer(String uuid)
      Stops test container by given uuid.
      Parameters:
      uuid - the uuid of container.
    • writeTestContainer

      public void writeTestContainer(String uuid)
      Writes test container with given uuid.
      Parameters:
      uuid - the uuid of container.
    • startPrepareFixture

      public void startPrepareFixture(String containerUuid, String uuid, io.qameta.allure.model.FixtureResult result)
      Start a new prepare fixture with given parent.
      Parameters:
      containerUuid - the uuid of parent container.
      uuid - the fixture uuid.
      result - the fixture.
    • startTearDownFixture

      public void startTearDownFixture(String containerUuid, String uuid, io.qameta.allure.model.FixtureResult result)
      Start a new tear down fixture with given parent.
      Parameters:
      containerUuid - the uuid of parent container.
      uuid - the fixture uuid.
      result - the fixture.
    • updateFixture

      public void updateFixture(Consumer<io.qameta.allure.model.FixtureResult> update)
      Updates current running fixture. Shortcut for updateFixture(String, Consumer).
      Parameters:
      update - the update function.
    • updateFixture

      public void updateFixture(String uuid, Consumer<io.qameta.allure.model.FixtureResult> update)
      Updates fixture by given uuid.
      Parameters:
      uuid - the uuid of fixture.
      update - the update function.
    • stopFixture

      public void stopFixture(String uuid)
      Stops fixture by given uuid.
      Parameters:
      uuid - the uuid of fixture.
    • getCurrentTestCase

      public Optional<String> getCurrentTestCase()
      Returns uuid of current running test case if any.
      Returns:
      the uuid of current running test case.
    • getCurrentTestCaseOrStep

      public Optional<String> getCurrentTestCaseOrStep()
      Returns uuid of current running test case or step if any.
      Returns:
      the uuid of current running test case or step.
    • setCurrentTestCase

      public boolean setCurrentTestCase(String uuid)
      Sets specified test case uuid as current. Note that test case with such uuid should be created and existed in storage, otherwise method take no effect.
      Parameters:
      uuid - the uuid of test case.
      Returns:
      true if current test case was configured successfully, false otherwise.
    • scheduleTestCase

      public void scheduleTestCase(String containerUuid, io.qameta.allure.model.TestResult result)
      Schedules test case with given parent.
      Parameters:
      containerUuid - the uuid of container.
      result - the test case to schedule.
    • scheduleTestCase

      public void scheduleTestCase(io.qameta.allure.model.TestResult result)
      Schedule given test case.
      Parameters:
      result - the test case to schedule.
    • startTestCase

      public void startTestCase(String uuid)
      Starts test case with given uuid. In order to start test case it should be scheduled at first.
      Parameters:
      uuid - the uuid of test case to start.
    • updateTestCase

      public void updateTestCase(Consumer<io.qameta.allure.model.TestResult> update)
      Shortcut for updateTestCase(String, Consumer) for current running test case uuid.
      Parameters:
      update - the update function.
    • updateTestCase

      public void updateTestCase(String uuid, Consumer<io.qameta.allure.model.TestResult> update)
      Updates test case by given uuid.
      Parameters:
      uuid - the uuid of test case to update.
      update - the update function.
    • stopTestCase

      public void stopTestCase(String uuid)
      Stops test case by given uuid. Test case marked as Stage.FINISHED and also stop timestamp is calculated. Result would be stored in memory until writeTestCase(String) method is called. Also stopped test case could be updated by updateTestCase(String, Consumer) method.
      Parameters:
      uuid - the uuid of test case to stop.
    • writeTestCase

      public void writeTestCase(String uuid)
      Writes test case with given uuid using configured AllureResultsWriter.
      Parameters:
      uuid - the uuid of test case to write.
    • startStep

      public void startStep(String uuid, io.qameta.allure.model.StepResult result)
      Start a new step as child step of current running test case or step. Shortcut for startStep(String, String, StepResult).
      Parameters:
      uuid - the uuid of step.
      result - the step.
    • startStep

      public void startStep(String parentUuid, String uuid, io.qameta.allure.model.StepResult result)
      Start a new step as child of specified parent.
      Parameters:
      parentUuid - the uuid of parent test case or step.
      uuid - the uuid of step.
      result - the step.
    • updateStep

      public void updateStep(Consumer<io.qameta.allure.model.StepResult> update)
      Updates current step. Shortcut for updateStep(String, Consumer).
      Parameters:
      update - the update function.
    • updateStep

      public void updateStep(String uuid, Consumer<io.qameta.allure.model.StepResult> update)
      Updates step by specified uuid.
      Parameters:
      uuid - the uuid of step.
      update - the update function.
    • stopStep

      public void stopStep()
      Stops current running step. Shortcut for stopStep(String).
    • stopStep

      public void stopStep(String uuid)
      Stops step by given uuid.
      Parameters:
      uuid - the uuid of step to stop.
    • addAttachment

      public void addAttachment(String name, String type, String fileExtension, byte[] body)
      Adds attachment into current test or step if any exists. Shortcut for addAttachment(String, String, String, InputStream)
      Parameters:
      name - the name of attachment
      type - the content type of attachment
      fileExtension - the attachment file extension
      body - attachment content
    • addAttachment

      public void addAttachment(String name, String type, String fileExtension, InputStream stream)
      Adds attachment to current running test or step.
      Parameters:
      name - the name of attachment
      type - the content type of attachment
      fileExtension - the attachment file extension
      stream - attachment content
    • prepareAttachment

      public String prepareAttachment(String name, String type, String fileExtension)
      Adds attachment to current running test or step, and returns source. In order to store attachment content use writeAttachment(String, InputStream) method.
      Parameters:
      name - the name of attachment
      type - the content type of attachment
      fileExtension - the attachment file extension
      Returns:
      the source of added attachment
    • writeAttachment

      public void writeAttachment(String attachmentSource, InputStream stream)
      Writes attachment with specified source.
      Parameters:
      attachmentSource - the source of attachment.
      stream - the attachment content.