Ranorex Webtestit
Published in

Ranorex Webtestit

Keeping Your Test Code Squeaky Clean with the Arrange, Act, Assert (AAA) Pattern

The Arrange, Act, Assert (AAA) pattern is a neat little strategy to help keep your test code cleaner and easier to read and maintain. In this article, we’ll show you the benefits of using this approach to structure your tests.

What is the AAA pattern?

The AAA stands for Arrange, Act, Assert, the three logical components that we should include when structuring our tests.

Using the AAA pattern in an actual test

We’ll use Ranorex Webtestit to take a closer look at each separate phase of the AAA pattern in action.
Ranorex Webtestit simplifies the whole testing process from scaffolding the test environment to using Page Objects to separating data from test logic. Another important thing is that when you create a new test file or generate a new test using snippets in Ranorex Webtestit, it already comes with the AAA pattern added in a form of comments to help you structure your test.


As we said, the Arrange part is where we prepare things for our test. In this case, that would be setting up a driver and opening Ranorex Webtestit Demoshop page that we’re going to use for this test.
The Arrange part is usually done manually, which can be a bit of a hassle as some scenarios may be more complicated than others.
However, the driver instance will be created automatically after you have created a new test file using Ranorex Webtestit, so you don’t have to worry about that setup code.
Also, the real preparation part is actually done in Page Objects, so all you need to do in the test is to right-click into the code editor and select “Instantiate Page Object” at the bottom of the context menu, as suggested by the Arrange comment.


In this step, we want to:

  1. Add all three items from the Items Overview page to the cart
  2. Perform a checkout
  3. Fill out the form and place an order


Assert is an evaluation step in which we compare the actual test result with the expected result.
In this test, we added three items in the cart and we expect the total amount to be €3,700.00.


In this article, we demonstrated how the AAA pattern could help structure our tests in such a way that we can easily differentiate between each separate phase from a test setup to the verification of results. Implementing this practice in our workflow ensures better readability and easier maintenance because anyone from our team can look at the test code and learn what behavior has been verified and why it has worked.



Ranorex Webtestit is a lightweight IDE that significantly reduces the effort to build robust and reliable UI tests for web applications.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store