Skip to content

[DOCS-13406] Add guide for conditional logic in Synthetic tests#34792

Open
git-thuerk-done wants to merge 6 commits intomasterfrom
alicia/docs-13406-conditional-logic-synthetic-tests
Open

[DOCS-13406] Add guide for conditional logic in Synthetic tests#34792
git-thuerk-done wants to merge 6 commits intomasterfrom
alicia/docs-13406-conditional-logic-synthetic-tests

Conversation

@git-thuerk-done
Copy link
Contributor

@git-thuerk-done git-thuerk-done commented Feb 24, 2026

What does this PR do? What is the motivation?

This stems from many support tickets and feature requests from customers requesting more information on conditional branching.

Fixes DOCS-13406
Adds a new guide covering how to implement conditional logic in Synthetic tests using subtests and step execution options. The guide addresses a documentation gap around the existing step execution options (allowFailure, exitIfSucceed,
alwaysExecute), which are available in the product but hard to discover and understand.

The guide covers three patterns for Browser, Multistep API, and Mobile App tests:

  • If/else-style flows — run different test paths based on which UI state the application presents (for example, A/B testing scenarios)
  • Element state-based logic — interact with the first available element using a custom locator and allow-failure behavior
  • Always-run cleanup steps — execute teardown steps regardless of whether earlier steps succeeded

Merge instructions

Merge readiness:

  • Ready for merge

For Datadog employees:

Your branch name MUST follow the <name>/<description> convention and include the forward slash (/). Without this format, your pull request will not pass CI, the GitLab pipeline will not run, and you won't get a branch preview. Getting a branch preview makes it easier for us to check any issues with your PR, such as broken links.

If your branch doesn't follow this format, rename it or create a new branch and PR.

[6/5/2025] Merge queue has been disabled on the documentation repo. If you have write access to the repo, the PR has been reviewed by a Documentation team member, and all of the required checks have passed, you can use the Squash and Merge button to merge the PR. If you don't have write access, or you need help, reach out in the #documentation channel in Slack.

Additional notes

@git-thuerk-done git-thuerk-done requested a review from a team as a code owner February 24, 2026 00:14
@git-thuerk-done git-thuerk-done added the WORK IN PROGRESS No review needed, it's a wip ;) label Feb 24, 2026
@github-actions github-actions bot added the Guide Content impacting a guide label Feb 24, 2026
@github-actions
Copy link
Contributor

@github-actions github-actions bot added the Images Images are added/removed with this PR label Feb 24, 2026
git-thuerk-done and others added 2 commits March 2, 2026 10:59
Copy link
Contributor

@domalessi domalessi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments and suggestions! Hit me up if you have Qs, and let me know when this is ready for another look :)


1. Add a subtest at the end of your test that contains only the cleanup or teardown steps.
2. In the subtest's advanced options, enable **Always run this step**.
3. Save the test. The cleanup subtest runs even when earlier steps have failed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the "always run this step" apply even if we have "If this step succeeds, stop this test and mark it as passed" earlier up in the chain?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes for this we want to capture the error and continue directly to step X from the step where it failed (i.e. in this pattern we don't want the "If this step succeeds, stop this test and mark it as passed" condition). hope that makes sense!

git-thuerk-done and others added 2 commits March 2, 2026 13:48
Co-authored-by: domalessi <111786334+domalessi@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Guide Content impacting a guide Images Images are added/removed with this PR WORK IN PROGRESS No review needed, it's a wip ;)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants