Best Practices: Use Small, Atomic, Autonomous Tests

  • 18 May 2021
  • 1 reply
  • 1326 views

Userlevel 1
Badge +1

When a test fails, the most important thing is knowing what went wrong so you can easily come up with a fix. The best way to know what went wrong is to keep three words in mind when designing your tests: Small, Atomic, and Autonomous.

Small

Small refers to the idea that your tests should be short and succinct. If you have a test suite of 100 tests running concurrently on 100 VMs, then the time it will take to run the entire suite will be determined by the longest/slowest test case. Keeping your tests small ensures that your suite will run efficiently and provide you with results faster. 

Atomic

An atomic test is one that focuses on testing a single feature, and which makes clear exactly what it is that you're testing. If the test fails, then you should also have a very clear idea of what needs to be fixed. 

Autonomous

An autonomous test is one that runs completely independently of other tests, and is not dependent on the results of one test to run successfully. In addition, an autonomous test should use its own data to test against, and not create potential conflicts with other tests over the same data. 


1 reply

Thanks saucelabs, if you can help me by clarifying something, this applies to unit tests and/or functional tests. In the case of E2E tests, if we take into account the pyramid of tests, how would we apply these rules? I see many cases where many scenarios are automated to test various parts of an E2E flow. In the automation of an E2E transaction I test many internal requirements, this would be fine.

Reply