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 working in testing for 20 years and is currently the lone tester for Geckoboard. He has been a Test Lead and has also worked as a part of waterfall, lean and agile teams. He is also Programme Secretary of BCS SIGiST. Mike has a B.Sc.(HONS) from Middlesex University and is an Associate of the University of Hertfordshire. He has set up and led a Testing Community of Practice and been part of a successful agile transition. He is Co-Programme Chair of the British Computer Society’s Specialist Interest Group in Software Testing. He also contributed to the e-book Testing Stories and has had articles published by the Ministry of Testing. Follow Mike on Twitter: @TestAndAnalysis

Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create your website with WordPress.com
Get started
%d bloggers like this: