Class Allure

java.lang.Object
io.qameta.allure.Allure

public final class Allure extends Object
The class contains some useful methods to work with AllureLifecycle.
  • Method Details

    • getLifecycle

      public static AllureLifecycle getLifecycle()
      Returns AllureLifecycle for low level operations with results.
      Returns:
      the lifecycle.
    • setLifecycle

      public static void setLifecycle(AllureLifecycle lifecycle)
      Sets the process-wide AllureLifecycle.
    • step

      public static void step(String name)
      Adds passed step with provided name in current test or step (or test fixture). Takes no effect if no test run at the moment. Shortcut for step(String, Status).
      Parameters:
      name - the name of step.
    • step

      public static void step(String name, io.qameta.allure.model.Status status)
      Adds step with provided name and status in current test or step (or test fixture). Takes no effect if no test run at the moment.
      Parameters:
      name - the name of step.
      status - the step status.
    • step

      public static void step(String name, Allure.ThrowableRunnableVoid runnable)
      Parameters:
      name - the name of step.
      runnable - the step's body.
    • step

      public static <T> T step(String name, Allure.ThrowableRunnable<T> runnable)
      Parameters:
      name - the name of step.
      runnable - the step's body.
    • step

      public static void step(Allure.ThrowableContextRunnableVoid<Allure.StepContext> runnable)
      Parameters:
      runnable - the step's body.
    • step

      public static void step(String name, Allure.ThrowableContextRunnableVoid<Allure.StepContext> runnable)
      Parameters:
      name - the name of step.
      runnable - the step's body.
    • step

      public static <T> T step(String name, Allure.ThrowableContextRunnable<T,Allure.StepContext> runnable)
      Parameters:
      name - the name of step.
      runnable - the step's body.
    • step

      public static <T> T step(Allure.ThrowableContextRunnable<T,Allure.StepContext> runnable)
      Run provided Allure.ThrowableRunnable as step with given name. Takes no effect if no test run at the moment.
      Parameters:
      runnable - the step's body.
    • stage

      public static void stage(String name)
      Starts a stage — a lightweight marker for a semantic test phase, rendered as a regular step. A stage has no explicit stop: it stays open, collecting the steps and attachments that follow, until the next stage starts or the enclosing step, test, or fixture ends. A stage started inside a step becomes a child of that step. Takes no effect if no test run at the moment.
      
       Allure.stage("prepare data");
       final Customer customer = createCustomer();
      
       Allure.stage("submit order");
       final Order order = submitOrder(customer);
      
       Allure.stage("verify result");
       assertThat(order.getStatus()).isEqualTo("created");
       
      Parameters:
      name - the name of the stage.
    • epic

      public static void epic(String value)
      Adds epic label to current test if any. Takes no effect if no test run at the moment. Shortcut for label(String, String).
      Parameters:
      value - the value of label.
    • feature

      public static void feature(String value)
      Adds feature label to current test if any. Takes no effect if no test run at the moment. Shortcut for label(String, String).
      Parameters:
      value - the value of label.
    • story

      public static void story(String value)
      Adds story label to current test if any. Takes no effect if no test run at the moment. Shortcut for label(String, String).
      Parameters:
      value - the value of label.
    • suite

      public static void suite(String value)
      Adds suite label to current test if any. Takes no effect if no test run at the moment. Shortcut for label(String, String).
      Parameters:
      value - the value of label.
    • label

      public static void label(String name, String value)
      Adds label to current test if any. Takes no effect if no test run at the moment.
      Parameters:
      name - the name of label.
      value - the value of label.
    • parameter

      public static <T> T parameter(String name, T value)
      Adds parameter to current test if any. Takes no effect if no test run at the moment.

      Shortcut for parameter(String, Object, Boolean, Parameter.Mode).

      Parameters:
      name - the name of parameter.
      value - the value of parameter.
    • parameter

      public static <T> T parameter(String name, T value, Boolean excluded)
      Adds parameter to current test if any. Takes no effect if no test run at the moment.

      Shortcut for parameter(String, Object, Boolean, Parameter.Mode).

      Parameters:
      name - the name of parameter.
      value - the value of parameter.
      excluded - true if parameter should be excluded from history key calculation, false otherwise.
      Returns:
      the specified value.
    • parameter

      public static <T> T parameter(String name, T value, io.qameta.allure.model.Parameter.Mode mode)
      Adds parameter to current test if any. Takes no effect if no test run at the moment.

      Shortcut for parameter(String, Object, Boolean, Parameter.Mode).

      Parameters:
      name - the name of parameter.
      value - the value of parameter.
      mode - the parameter mode.
      Returns:
      the specified value.
    • parameter

      public static <T> T parameter(String name, T value, Boolean excluded, io.qameta.allure.model.Parameter.Mode mode)
      Adds parameter to current test if any. Takes no effect if no test run at the moment.
      Parameters:
      name - the name of parameter.
      value - the value of parameter.
      excluded - true if parameter should be excluded from history key calculation, false otherwise.
      mode - the parameter mode.
      Returns:
      the specified value.
    • issue

      public static void issue(String name, String url)
      Adds issue link to current test if any. Takes no effect if no test run at the moment. Shortcut for link(String, String, String).
      Parameters:
      name - the name of link.
      url - the link's url.
    • tms

      public static void tms(String name, String url)
      Adds tms link to current test if any. Takes no effect if no test run at the moment. Shortcut for link(String, String, String).
      Parameters:
      name - the name of link.
      url - the link's url.
    • link

      public static void link(String url)
      Adds link to current test if any. Takes no effect if no test run at the moment. Shortcut for link(String, String)
      Parameters:
      url - the link's url.
    • link

      public static void link(String name, String url)
      Adds link to current test if any. Takes no effect if no test run at the moment. Shortcut for link(String, String, String)
      Parameters:
      name - the name of link.
      url - the link's url.
    • link

      public static void link(String name, String type, String url)
      Adds link to current test if any. Takes no effect if no test run at the moment.
      Parameters:
      name - the name of link.
      type - the type of link, used to display link icon in the report.
      url - the link's url.
    • description

      public static void description(String description)
      Adds description to current test if any. Takes no effect if no test run at the moment. Expecting description provided in Markdown format.
      Parameters:
      description - the description in markdown format.
      See Also:
    • descriptionHtml

      public static void descriptionHtml(String descriptionHtml)
      Adds descriptionHtml to current test if any. Takes no effect if no test run at the moment. Note that description will take no effect if descriptionHtml is specified.
      Parameters:
      descriptionHtml - the description in html format.
      See Also:
    • globalError

      public static void globalError(Throwable throwable)
      Adds an error from the given throwable that belongs to the test run rather than to a test or fixture. The error is passed synchronously to the configured results writer before this method returns. Writers that support globals store it in a new globals artifact.
      Parameters:
      throwable - the error to add
    • globalError

      public static void globalError(io.qameta.allure.model.StatusDetails statusDetails)
      Adds an error with the given status details that belongs to the test run rather than to a test or fixture. The error is passed synchronously to the configured results writer before this method returns. Writers that support globals store it in a new globals artifact. The status detail fields are copied without normalization, and the timestamp is assigned when this method is called.
      Parameters:
      statusDetails - the error details to add
    • attachment

      public static void attachment(String name, String content)
      Adds attachment.
      Parameters:
      name - the name of attachment.
      content - the attachment content.
    • attachment

      public static void attachment(String name, InputStream content)
      Adds attachment.
      Parameters:
      name - the name of attachment.
      content - the stream that contains attachment content.
    • attachment

      public static void attachment(String name, String type, String content)
      Adds attachment.
      Parameters:
      name - the name of attachment.
      type - the content type of attachment.
      content - the attachment content.
    • attachment

      public static void attachment(String name, String type, String content, AttachmentOptions options)
      Adds attachment.
      Parameters:
      name - the name of attachment.
      type - the content type of attachment.
      content - the attachment content.
      options - the attachment options.
    • attachment

      public static void attachment(String name, String type, InputStream content, AttachmentOptions options)
      Adds attachment.
      Parameters:
      name - the name of attachment.
      type - the content type of attachment.
      content - the stream that contains attachment content.
      options - the attachment options.
    • attachmentAsync

      public static CompletableFuture<Void> attachmentAsync(String name, String type, CompletionStage<? extends InputStream> body)
      Adds an async attachment and waits for its content before the owning executable ends.
      Parameters:
      name - the name of attachment.
      type - the content type of attachment.
      body - the future stream that contains attachment content.
      Returns:
      future completed when attachment content is written.
    • attachmentAsync

      public static CompletableFuture<Void> attachmentAsync(String name, String type, CompletionStage<? extends InputStream> body, AttachmentOptions options)
      Adds an async attachment and waits for its content before the owning executable ends.
      Parameters:
      name - the name of attachment.
      type - the content type of attachment.
      body - the future stream that contains attachment content.
      options - the attachment options.
      Returns:
      future completed when attachment content is written.
    • addHttpExchange

      public static void addHttpExchange(String name, HttpExchange exchange)
      Adds an HTTP exchange attachment.

      Build the exchange with the desired capture options before calling this method. This method only writes the already captured exchange.

      Parameters:
      name - the attachment name
      exchange - the HTTP exchange payload