Creating Fast, Reliable, Focused UI Automation With Atomic Tests

Nikolay Advolodkin
Mar 4, 2020 · 9 min read

What is an atomic automated test?

Your automated test should form a single irreducible unit. This means that your tests should be extremely focused and test only a single thing. A single automated test should not do something like end-to-end automation.

  • Atomic tests have very few UI interactions and they’re only on a maximum of two screens. In rare cases, an atomic test might navigate through 3 screens (although I’d like to see this example)

Problems solved by atomic tests

  • Unreliable automated test results
  • Slow tests
  • Tests that are hard to debug
  • Tests that don’t provide the correct point of failure

500% Reduction in Test Suite Execution Time (Case Study)

In a recent case study, we found that 18 long end to end tests ran in ~20 min. Using a much larger suite of 180 atomic tests, with the same exact code coverage, running in parallel, we were able to decrease the entire suite execution time to ~4min.

Advantages of atomic tests

1. Atomic tests fail fast

First, writing atomic tests allows you to fail fast and fail early. This implies that you will get extremely fast and focused feedback. If you want to check the state of a feature, it will take you no longer than 1 minute.

2. Atomic tests decrease flaky behaviour

  1. Assert that the page opened
  2. Assert that each section on the page exists
  3. Open Blog page
  4. Search for an article
  5. Assert that the article exists

3. Atomic checks allow for better testing

The third benefit of writing atomic tests is that if it fails, it will not block other functionality from being tested. For example, the test I mentioned above. If it fails on Step 3, then you might never get to check if the Blog page works or that the Search functionality works. Assuming that you don’t have other tests to check this functionality. As a result of a large test, you will reduce your test coverage.

4. Atomic tests are short and fast

Finally, another great benefit of writing atomic tests is that they will run quicker when parallelized…

How I got a 98% performance enhancement in test execution speed with a single change?

Case Study of Amazing Automation:

How to break up giant end-to-end UI tests?

  1. Assert that the page opens
  2. Search for an item
  3. Assert that item is found
  4. Add item to cart
  5. Assert that item is added
  6. Checkout
  7. Assert that checkout is complete
How to break up e2e tests into atomic tests

How to manipulate test data for UI automation?

You can inject data via several options:

  1. Using JavaScript
  2. Injecting data into the DB to set the application in a certain state
  3. Using cookies
  1. Use an API that will generate an item in your Amazon cart
  2. Now you can pull up the UI to the cart page and checkout using web automation
  3. Clean up all test data after

How To Control App State Using JavaScript?

Probably the most common impediment to atomic testing is the login screen. And most of our apps have one.

How to bypass a login mechanism using JavaScript injection

How To Coordinate API and UI Interactions In One Test?

What if you wanted to coordinate API and UI actions in a single test? Well, that would look something like this.

What if you can’t inject data for testing?

I know that the world isn’t perfect and many of us aren’t lucky enough to have applications that are developed with testability in mind.

Bob Martin on professionalism

What do you think? Can you write atomic tests in your application?

The Startup

Get smarter at building your thing. Join The Startup’s +788K followers.

Thanks to The Startup

Sign up for Top 10 Stories

By The Startup

Get smarter at building your thing. Subscribe to receive The Startup's top 10 most read stories — delivered straight into your inbox, once a week. Take a look.

By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about our privacy practices.

Check your inbox
Medium sent you an email at to complete your subscription.

Nikolay Advolodkin

Written by

Nikolay Advolodkin is a self-driven SDET on a lifelong mission to create profound change in the IT world and ultimately leave a legacy for his loved ones

The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +788K followers.

Nikolay Advolodkin

Written by

Nikolay Advolodkin is a self-driven SDET on a lifelong mission to create profound change in the IT world and ultimately leave a legacy for his loved ones

The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +788K followers.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

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