Automated test : UI vs API

When you start to have too many UI tests and it takes hours to complete them, maybe something is wrong in term of automated test strategy.

The first reaction when it takes ages, you start to run nightly test, revise them one by one and find eventually duplicates and finally try parallelize them when it is possible. And if this is still not enough?

Maybe you should define the most critical (20-30%) and modify the other using API calls instead of using UI.

When you test modern application with multiple layer, the UI layer should have no logic and no data. That means if you execute on API or UI level you should have the same results. But on API level the test are more quicker. In fact what you should test on the UI side is if the UI is behaving properly using the API and the security is aligned with the API, then the rest all should be done on API side.

Moving test from UI to API is not obvious because you may also modify all the UI test to cover the alignment between UI and API.

This is why you should think from the beginning to adopt the right test automation strategy with a good balance between API and UI!

For project using open source tool, RestAssured is a good choice to automatized API test. In this Github repository, you could find an example on how to use API test.

Leave a Reply

Your email address will not be published. Required fields are marked *