To Automate API Tests or FrontEnd Tests?

Ravi Shankar Pandey
2 min readAug 30, 2021

In modern applications where microservices are essential to the core, this question becomes important to answer.

There are pros and cons of both strategies. Let’s look at them.

Pros of API Workflow Test Automation:

  1. API tests execute faster. I have a test suite of API tests comprising 200+ test scenarios, that executes within 6 minutes.
  2. API tests are rarely flaky and so are the false positives or negatives.
  3. API tests are easier to maintain.
  4. Code reusability is higher as the same API gets called in multiple workflows.

Cons of API test automation:

  1. Over-indexing on API workflow testing and automation can leave front ends (websites and apps) untested.
  2. One cannot get 100% automation coverage alone with API workflow test automation.
  3. The size of the test case file (feature file or any other test case documentation methodology) increases as the same steps (API calls) repeats for different workflows.

Pros of Front-end Tests:

  1. Front-end tests mimic end-user actions.
  2. More test developers are well versed in front-end testing and automation. So, talent is more abundant for front-end testing.

Cons of Front-end Tests:

  1. Front-end tests execute slower.
  2. Front-end tests are flaky as there are multiple variables involved, tuning them to the correct wait time becomes a task on its own e.g. page load time, network latency, API response time.
  3. In a fast-paced development environment, front-end tests are costly to maintain as web pages are continuously evolving with a high degree of variance between two versions.

So, what should be the best strategy in microservices architecture?

  1. To avoid delayed execution time and test flakiness, API workflow testing and automation seem to be a great option.
  2. However, this leaves the front-end unattended.
  3. Over-indexing on API workflow automation along with the automation of business-critical user flows on websites and apps should be the best strategy.
  4. This strategy makes sure that the tradeoff between velocity and quality is minimal.
  5. With this strategy, one can achieve maximum test automation coverage.

--

--

Ravi Shankar Pandey

@ravipndey on Twitter. Views expressed on this blog are solely mine, not those of present or past employers