The Test Automation Pyramid
The test automation pyramid proposed by Mike Cohn can help you find the best approach to test automation.
The most straightforward approach to test automation is just to take test cases created for manual testing and automate them at the level of user interface (GUI) using tools like Selenium. Nevertheless, this is the least efficient approach. Automated GUI tests are longer-running, vulnerable to any changes and hard to maintain.
Mike Cohn’s automation pyramid is an excellent illustration of a more efficient approach. The width of each pyramid level shows how many tests should be there in comparison to other levels.
Unit tests are at the bottom level of the pyramid. They should represent the majority of your tests. For example, to test a class that computes interest in an amount, you should create a unit test rendering the interest rate x and balance y. The expected result: Correct computation of the interest amount with required accuracy.
The middle level refers to tests that verify business behavior (but not through GUI!). Such tests are sometimes called API tests. If you use the behavior-driven development (BDD) methodology, your automated tests will refer to that level. You may need quite a large number of unit tests at this level, yet less than unit tests. Such tests can cover several components simultaneously and check the product behavior in terms of business. Example: After computing the interest on the deposit, the required amount is added to the balance.
Find out more at — http://bit.ly/30v69Zu