Use a failure reason in a test script

Use the Smart Reporting SDK and the External Test Information SDK to tag a test result with a specific failure reason. In code, you supply the reason through the TestResultFactory.createFailure(...) method, which accepts a failure message, the throwable, and the failure reason ID copied from the Failure reasons tab. If the ID does not match a defined reason, the SDK ignores it.

Parameters supported by the TestResultFactory method

  • Failure message: Text added to the test report

  • Throwable: The actual error/exception associated with the failure

  • Failure reason ID: A string that must match an ID defined in the UI (unmatched IDs are ignored)

Example (Java)

Copy
import com.perfectomobile.reporting.TestResult;
import com.perfectomobile.reporting.TestResultFactory;

// Create a failure and tag it with a predefined failure reason ID.
// Paste the failure reason ID after copying it from the Failure reasons tab.
TestResult testResult = TestResultFactory.createFailure("Test stop failure", e, "bEC3xAdMTz");
reportiumClient.testStop(testResult);
``

For a complete sample, see Reporting Samples – SimpleTest.java on GitHub.

What’s next