Introducing me:
I am Jag Singh, I have been a Test Automation Engineer and Software Developer for about 10 years. I have spent equal amounts of time in automating the user interface and automating the API’s such as Rest and Soap services.
Why Automated API testing is trending more than the GUI?
Agile is becoming the most common delivery model for software applications. The main selling point of agile to business is to deliver features to market as fast as possible and deliver more regularly.
As we deliver the awesome features in iterations; we need to regression test the features we have built in the previous iterations. We do this using continuous integration tools and techniques; where the automated tests run as part of the build process to provides a quick feedback on broken features.
The GUI tests are slow. Imagine you want to achieve a great coverage through the GUI and you have to have hundreds of tests running that would make the continuous feedback really slow. Sure you can make them run overnight or use tools such as saucelabs or selenium grid to run the tests in parallel but testing the application through UI is going to be slow specially if your application has complex workflows or has large number of fields. Quicker feedback is essential in Agile. The sooner you can give feedback to your team about a broken build the better off you are going to be! If you have done GUI testing for long enough you will know, they are hard to develop, hard maintain and hard to make reliable!
Well enough on GUI now. We all know GUI is important to test end to end but it is about to find the right balance.
The famous test pyramid has got the clues!
As we discussed GUI tests are hard to create, slow and cost $$$ (well time is money!) so you should focus on getting the UI coverage to 10–20%.
Service/API layer tests are the middle sweet spot. API tests are fairly easy to develop, maintain and run. So you can majority of your business logic in this layer.
Unit level test cases are the easiest, cheapest and fastest! Well I will cover this later and it is going to be an upcoming area to watch this space.
But you will say this is not a new thing! API has been there forever
Well it is becoming more important now than before due to the technology advancements such as Internet of things (IOT) and AI. We will have more application coming up in areas such as smart homes, smart cities, connected cars and much more. We will land in to a world where we have little or no GUI and hence API will become the new king!
References: