Assertions

What is an assertion?

An assertion is a logical expression that captures an expectation about the state of an application screen. An assertion is what turns a flow into a test. Waldo supports several kinds of assertions:

  • A text assertion verifies that a specific element on the screen displays a specific text.
  • A box assertion verifies that a specific section of the screen renders correctly.
  • A screen assertion verifies that the overall screen meets certain criteria.

During replay, assertions serve two important purposes:

  • They enforce that the application is behaving correctly and allow tests to have both functional and UI coverage of the app.
  • They can help determine when a screen has properly loaded, by determining what elements of the screen should be present.

Assertions are a powerful tool in Waldo that you can use to identify potential regressions in your build. Waldo does not limit the number of assertions you can assigned to a flow. We recommend using assertions as often as necessary.

Creating an assertion

Once you finish recording your test, you can create a new assertion for it by performing the following steps:

  1. Click on the “Tests” tab to display the overview of all your tests.
  1. Click on the particular screen in the test you wish to create the assertion for. Waldo displays a list of all assertions for this particular screen.
  1. Click the Add new assertion button in the lower right of the modal window. Waldo displays a list of the assertion types you can create as well as configuration steps for the desired assertion.
  1. Select the type of assertion you wish to create and then follow the step-by-step instructions to configure it. When you finish, click the Save Assertion button in the lower right of the modal window. Waldo agains displays the list of all assertions for this particular screen, including the new assertion.

You've created your first assertion! Notice that Waldo displays a badge near the top-right corner of each screen of a test flow:

  • The badge is purple and contains the number of assertions created for that screen.
  • The badge is green with a + if there are no assertions created for that screen.

Now that your assertions are created, every time this test is run, we evaluate the assertions and compare them to the baseline of this test i.e. the state of the test when recorded.

Types of assertions

As seen in the previous section, Waldo makes it possible to create different types of assertions.

In the “What is an assertion?" section, we have also seen that the test assertion concept is broad and it is nearly impossible to cover all cases.

After many iterations and with the help of our customers, we have selected the most important types of assertions to help you cover most cases and catch the majority of bugs.

For more on each type of assertion, visit:

Using assertions in your tests

Whenever Waldo runs your tests, it evaluates each assertion in each test. This, of course, affects the results of the run. For more on running your tests, please visit Run Tests.

Assertion success

If all assertions in all tests in the run evaluate true, then Waldo considers that run to have “passed”.

Note: Your run can still fail for other reasons (for example, an application crash).

Assertion failure

If any assertion in any test in the run evaluates false, then Waldo considers that run to have “failed”.

Visit the detailed view of your run to determine which assertions are failing. Waldo displays a red badge near the top-right corner of each screen in the test flow with a failing assertion.

To understand how to best recover from failing assertions visit Fixing Assertions