Decreasing the Chances of Flaky Tests

There are so many internal and external factors that can cause flaky tests that is very unlikely for any testing project to completely get rid of them. However, besides the proactive solutions we discussed in the previous section, there are also some steps that we can follow before and while writing tests to decrease the chances of encountering flaky tests:

  1. Do not wait for a flaky test to present itself during the execution phase. Instead, try to follow and apply the tips from the previous section while designing and writing your tests.
  2. Use patterns as Page Object Model to separate your projects into layers (test code, user interface code, and so on). This will help you to build more robust tests, and will make way easier to find the causes of errors and flaky tests.
  3. Use test frameworks and the proper tools to design, write, and execute your test. By following the guidelines of a test framework, it is more unlikely for flaky tests to take place.
  4. Once you have identified and solved a flaky test (even if you did not solve it), document it. You could include information about the specific error messages, the software and testing scenarios, and the ratio of failure of the test. You could also document the different solutions attempts and how they make the test worse or better, how you came out with the solution, or how you did not and what workaround you decide to follow, and any other information that can be useful for you of future members of your team.

We are now able to understand how to identify and attempt to solve flaky tests.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.32.116