API Testing can enhance automated testing strategy

An automated test strategy will normally include tests that are automated through the UI, and unit tests. It is an advantage if an automated testing strategy also includes testing that is automated via the API.

Automated tests need to run quickly so that developers get fast feedback on their work. Tests that are automated via the UI can take a long time to run as a UI has to be fired up for each test, this means that it is difficult to use automated testing via UI to automate a large number of workflows as they will take too long to run. Tests that are automated via the API are integration tests just like tests that are automated via the UI, however API tests have the advantage that they run quickly as they do not require the user interface.

Unit tests run quickly and give confidence that individual components of the code do what they are supposed to but don’t help you have confidence that the whole application works as it should. Tests that are automated via the API run quickly like unit tests and help give confidence in the application because they are integration tests.

Tests that run through the UI can also require maintenance when the UI changes, for example, the css selectors that they use may have been changed. This creates a maintenance overhead when the UI changes. Tests that are automated via the UI can also be flaky because sometimes the UI can take longer to render or a test relies on a complex relative xpath or some other reason. Flaky tests can undermine developers’ confidence in automated testing and create maintenance work for whoever is maintaining the tests. Tests that are automated via the API do not have these maintenance issues as they do not use the UI.

Tests that are automated via the API have many advantages and can be used to enhance test automation strategy. They run quickly, can be used to increase integration test coverage by automating tests of many workflows, can give confidence in the application and do not have a large maintenance overhead.

Further reading: Testing Web APIs

Published by Mike Harris

Mike has been a testing professional for over 20 years. He has been a Test Lead and has also worked as a part of waterfall, lean and agile teams. He has set up and led a Testing Community of Practice and been part of a successful agile transition. He is Vice-Chair of the British Computer Society’s Specialist Interest Group in Software Testing. He also contributed to the e-books Testing Stories and How Can I test This?

Leave a comment

Design a site like this with WordPress.com
Get started