Skip to main content
No Result Found
Connect and get help from 7,000+ developers on our Discord community. Ask the CommunityAsk the Community

Pattern-based failure analysis

Automatically assign failure categories to failed tests by matching their stack traces against regex or string patterns.

Pattern-based failure analysis allows you define rules that scan error messages and stack traces for specific strings or regex patterns. When a match is found, BrowserStack Test Reporting & Analytics automatically assigns the corresponding failure category to the test. Tests assigned this way are labeled Pattern-matched in the test view.

This platform feature is available with Automate, App Automate, Test Management, Test Reporting & Analytics, and Automate TurboScale.

Prerequisite

  • This feature is available only on paid plans.

Enable pattern analysis

Follow these steps to enable pattern-based failure analysis:

  1. In the left sidebar, go to Settings.
  2. Select Pattern Analysis.
  3. Turn on the Pattern Analysis toggle.

The Pattern Analysis settings page showing the feature toggle enabled and a No Patterns empty state with the Create new pattern button

Create a pattern rule

Follow these steps to create a pattern rule:

  1. Click Settings on left sidebar.
  2. Click Pattern Analysis.
  3. Click Create.
  4. Enter a regex or string pattern in the Pattern field. The system supports standard regex syntax.
  5. Select a failure category from the Failure category dropdown.
  6. In the First N lines field, enter the number of lines of the error message and stack trace to analyze. The default is 5.
  7. Click Save.

The new rule appears in the Pattern Rules table with the status Enabled.

Pattern rules are evaluated in priority order. Assign a lower priority number to rules that should take precedence when multiple rules match the same stack trace.

Manage pattern rules

You can edit, enable, disable, or delete rules in pattern analysis.

Edit a rule

Follow these steps to edit a rule:

  1. Click the options menu (â‹®) next to a rule .
  2. Select Edit.
  3. Update the fields.
  4. Click Save.

Enable or disable a rule

Follow these steps to enable or disable a rule:

  1. Click the options menu next to a rule.
  2. Select Enable or Disable.

Disabled rules are skipped during pattern matching.

Delete a rule

Follow these steps to delete a rule:

  1. Click the options menu next to a rule.
  2. Select Delete.

Deleted rules can’t be recovered.

How pattern matching works

When a test fails, BrowserStack Test Reporting & Analytics evaluates each enabled pattern rule against the test’s error message and stack trace in priority order:

  • Rules are checked from highest priority (1) to lowest.
  • The failure category from the first matching rule is assigned to the test.
  • Pattern-based matching takes precedence over AI-based failure category assignment. If a pattern rule matches, Automatic Failure Analysis is not applied to that test.
  • If no pattern rule matches, the system falls back to Automatic Failure Analysis if it’s enabled.

The Pattern Analysis settings page showing two configured rules with their priority, pattern, status, and assigned failure category

The First N lines setting limits the portion of the stack trace scanned by each rule. Analyzing fewer lines improves performance and reduces noise from deeply nested trace entries. Increase this value if the error you’re matching appears further down the stack trace.

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback!

Talk to an Expert
Download Copy Check Circle