Class ResultsUtils

java.lang.Object
io.qameta.allure.util.ResultsUtils

public final class ResultsUtils extends Object
Utility methods for creating and enriching Allure result model objects.

Use these helpers when custom integrations need labels, links, parameters, names, descriptions, status details, or test plan identifiers in the same format as the built-in adapters.

  • Field Details

  • Method Details

    • createParameter

      public static io.qameta.allure.model.Parameter createParameter(String name, Object value)
      Creates and returns the parameter.
      Parameters:
      name - the display name or logical name to use
      value - the value to set
      Returns:
      the parameter
    • createParameter

      public static io.qameta.allure.model.Parameter createParameter(String name, Object value, Boolean excluded, io.qameta.allure.model.Parameter.Mode mode)
      Creates and returns the parameter.
      Parameters:
      name - the display name or logical name to use
      value - the value to set
      excluded - the excluded
      mode - the mode
      Returns:
      the parameter
    • createSuiteLabel

      public static io.qameta.allure.model.Label createSuiteLabel(String suite)
      Creates and returns the suite label.
      Parameters:
      suite - the TestNG suite callback argument
      Returns:
      the suite label
    • createParentSuiteLabel

      public static io.qameta.allure.model.Label createParentSuiteLabel(String suite)
      Creates and returns the parent suite label.
      Parameters:
      suite - the TestNG suite callback argument
      Returns:
      the parent suite label
    • createSubSuiteLabel

      public static io.qameta.allure.model.Label createSubSuiteLabel(String suite)
      Creates and returns the sub suite label.
      Parameters:
      suite - the TestNG suite callback argument
      Returns:
      the sub suite label
    • createTestMethodLabel

      public static io.qameta.allure.model.Label createTestMethodLabel(String testMethod)
      Creates and returns the test method label.
      Parameters:
      testMethod - the test method
      Returns:
      the test method label
    • createTestClassLabel

      public static io.qameta.allure.model.Label createTestClassLabel(String testClass)
      Creates and returns the test class label.
      Parameters:
      testClass - the test class
      Returns:
      the test class label
    • createPackageLabel

      public static io.qameta.allure.model.Label createPackageLabel(String packageName)
      Creates and returns the package label.
      Parameters:
      packageName - the package name
      Returns:
      the package label
    • createTitlePath

      public static List<String> createTitlePath(String... values)
      Creates and returns the title path.
      Parameters:
      values - the values
      Returns:
      the title path
    • createTitlePath

      public static List<String> createTitlePath(Collection<String> values)
      Creates and returns the title path.
      Parameters:
      values - the values
      Returns:
      the title path
    • createTitlePathFromPackageAndClass

      public static List<String> createTitlePathFromPackageAndClass(String packageName, String className)
      Creates and returns the title path from package and class.
      Parameters:
      packageName - the package name
      className - the class name
      Returns:
      the title path from package and class
    • createTitlePathFromQualifiedClassName

      public static List<String> createTitlePathFromQualifiedClassName(String className)
      Creates and returns the title path from qualified class name.
      Parameters:
      className - the class name
      Returns:
      the title path from qualified class name
    • createTitlePathFromJavaClass

      public static List<String> createTitlePathFromJavaClass(Class<?> clazz)
      Creates and returns the title path from java class.
      Parameters:
      clazz - the clazz
      Returns:
      the title path from java class
    • createTitlePathFromPackage

      public static List<String> createTitlePathFromPackage(String packageName)
      Creates and returns the title path from package.
      Parameters:
      packageName - the package name
      Returns:
      the title path from package
    • createTitlePathFromSourcePath

      public static List<String> createTitlePathFromSourcePath(String sourcePath)
      Creates and returns the title path from source path.
      Parameters:
      sourcePath - the source path
      Returns:
      the title path from source path
    • createEpicLabel

      public static io.qameta.allure.model.Label createEpicLabel(String epic)
      Creates and returns the epic label.
      Parameters:
      epic - the epic
      Returns:
      the epic label
    • createFeatureLabel

      public static io.qameta.allure.model.Label createFeatureLabel(String feature)
      Creates and returns the feature label.
      Parameters:
      feature - the feature
      Returns:
      the feature label
    • createStoryLabel

      public static io.qameta.allure.model.Label createStoryLabel(String story)
      Creates and returns the story label.
      Parameters:
      story - the story
      Returns:
      the story label
    • createTagLabel

      public static io.qameta.allure.model.Label createTagLabel(String tag)
      Creates and returns the tag label.
      Parameters:
      tag - the tag
      Returns:
      the tag label
    • createOwnerLabel

      public static io.qameta.allure.model.Label createOwnerLabel(String owner)
      Creates and returns the owner label.
      Parameters:
      owner - the owner
      Returns:
      the owner label
    • createSeverityLabel

      public static io.qameta.allure.model.Label createSeverityLabel(SeverityLevel severity)
      Creates and returns the severity label.
      Parameters:
      severity - the severity
      Returns:
      the severity label
    • createSeverityLabel

      public static io.qameta.allure.model.Label createSeverityLabel(String severity)
      Creates and returns the severity label.
      Parameters:
      severity - the severity
      Returns:
      the severity label
    • createHostLabel

      public static io.qameta.allure.model.Label createHostLabel()
      Creates and returns the host label.
      Returns:
      the host label
    • createThreadLabel

      public static io.qameta.allure.model.Label createThreadLabel()
      Creates and returns the thread label.
      Returns:
      the thread label
    • createFrameworkLabel

      public static io.qameta.allure.model.Label createFrameworkLabel(String framework)
      Creates and returns the framework label.
      Parameters:
      framework - the framework
      Returns:
      the framework label
    • createLanguageLabel

      public static io.qameta.allure.model.Label createLanguageLabel(String language)
      Creates and returns the language label.
      Parameters:
      language - the language
      Returns:
      the language label
    • createLabel

      public static io.qameta.allure.model.Label createLabel(String name, String value)
      Creates and returns the label.
      Parameters:
      name - the display name or logical name to use
      value - the value to set
      Returns:
      the label
    • createLabel

      public static io.qameta.allure.model.Label createLabel(Owner owner)
      Creates and returns the label.
      Parameters:
      owner - the owner
      Returns:
      the label
    • createLabel

      public static io.qameta.allure.model.Label createLabel(Severity severity)
      Creates and returns the label.
      Parameters:
      severity - the severity
      Returns:
      the label
    • createLabel

      public static io.qameta.allure.model.Label createLabel(Story story)
      Creates and returns the label.
      Parameters:
      story - the story
      Returns:
      the label
    • createLabel

      public static io.qameta.allure.model.Label createLabel(Feature feature)
      Creates and returns the label.
      Parameters:
      feature - the feature
      Returns:
      the label
    • createLabel

      public static io.qameta.allure.model.Label createLabel(Epic epic)
      Creates and returns the label.
      Parameters:
      epic - the epic
      Returns:
      the label
    • createIssueLink

      public static io.qameta.allure.model.Link createIssueLink(String value)
      Creates and returns the issue link.
      Parameters:
      value - the value to set
      Returns:
      the issue link
    • createTmsLink

      public static io.qameta.allure.model.Link createTmsLink(String value)
      Creates and returns the tms link.
      Parameters:
      value - the value to set
      Returns:
      the tms link
    • createLink

      public static io.qameta.allure.model.Link createLink(Link link)
      Creates and returns the link.
      Parameters:
      link - the link
      Returns:
      the link
    • createLink

      public static io.qameta.allure.model.Link createLink(Issue link)
      Creates and returns the link.
      Parameters:
      link - the link
      Returns:
      the link
    • createLink

      public static io.qameta.allure.model.Link createLink(TmsLink link)
      Creates and returns the link.
      Parameters:
      link - the link
      Returns:
      the link
    • createLink

      public static io.qameta.allure.model.Link createLink(String value, String name, String url, String type)
      Creates and returns the link.
      Parameters:
      value - the value to set
      name - the display name or logical name to use
      url - the request URL or service method name
      type - the event or label type
      Returns:
      the link
    • getProvidedLabels

      public static Set<io.qameta.allure.model.Label> getProvidedLabels()
      Returns the provided labels.
      Returns:
      the provided labels
    • getHostName

      public static String getHostName()
      Returns the host name.
      Returns:
      the host name
    • getThreadName

      public static String getThreadName()
      Returns the thread name.
      Returns:
      the thread name
    • getStatus

      public static Optional<io.qameta.allure.model.Status> getStatus(Throwable throwable)
      Returns the status.
      Parameters:
      throwable - the throwable
      Returns:
      the status
    • getStatusDetails

      public static Optional<io.qameta.allure.model.StatusDetails> getStatusDetails(Throwable e)
      Returns the status details.
      Parameters:
      e - the e
      Returns:
      the status details
    • createGlobalError

      public static io.qameta.allure.model.Globals createGlobalError(String context, Throwable throwable)
      Returns the globals artifact for a failure that belongs to the test run rather than to any test result.

      Adapters use this for failures they cannot attribute to a test without inventing one: a configuration method that failed outside any test, or a data provider that failed before the invocations it would have produced were known. A test result invented for such a failure carries a history id that no execution ever produces, so it distorts the run statistics and no retry can ever replace it.

      Write the result with AllureLifecycle.writeGlobals(Globals) on the adapter's own lifecycle rather than through the Allure facade, so that the error reaches the lifecycle the adapter reports to.

      Parameters:
      context - the description of what failed, and of what did not run when the failure kept tests from running
      throwable - the failure, may be null
      Returns:
      the globals artifact holding a single error
    • getJavadocDescription

      public static Optional<String> getJavadocDescription(ClassLoader classLoader, Method method)
      Returns the javadoc description.
      Parameters:
      classLoader - the class loader to use for resource lookup
      method - the framework or Java method to inspect
      Returns:
      the javadoc description
    • firstNonEmpty

      public static Optional<String> firstNonEmpty(String... items)
      Returns the first non empty.
      Parameters:
      items - the map entries to convert
      Returns:
      the first non empty
    • getLinkTypePatternPropertyName

      public static String getLinkTypePatternPropertyName(String type)
      Returns the link type pattern property name.
      Parameters:
      type - the event or label type
      Returns:
      the link type pattern property name
    • generateMethodSignatureHash

      public static String generateMethodSignatureHash(String className, String methodName, List<String> parameterTypes)
      Generates and returns the method signature hash.
      Parameters:
      className - the class name
      methodName - the method name
      parameterTypes - the parameter types
      Returns:
      the generated method signature hash
    • md5

      public static String md5(String source)
      Returns the md5.
      Parameters:
      source - the source
      Returns:
      the md5
    • getLambdaName

      public static Optional<String> getLambdaName(Object lambda)
      Returns the lambda name.
      Parameters:
      lambda - the lambda
      Returns:
      the lambda name
    • bytesToHex

      public static String bytesToHex(byte[] bytes)
      Returns the bytes to hex.
      Parameters:
      bytes - the bytes
      Returns:
      the bytes to hex
    • getMd5Digest

      public static MessageDigest getMd5Digest()
      Returns the md5 digest.
      Returns:
      the md5 digest
    • processDescription

      public static void processDescription(ClassLoader classLoader, Method method, Consumer<String> setDescription, Consumer<String> setDescriptionHtml)
      Handles the process description callback.
      Parameters:
      classLoader - the class loader to use for resource lookup
      method - the framework or Java method to inspect
      setDescription - the set description
      setDescriptionHtml - the set description html