Unit Tests, UI Tests, Integration Tests & End-To-End Tests
As we write more sophisticated software, we want to be confident that our application continues to work as we add new features and/or refactor our codebase.
In this Testing Pyramid, which was introduced by Mike Cohn, re-designed by Marin Fowler and re-engineered by me, summarises the essential types of tests a software should have. Let me put them into two main categories:
Programmatic Tests help us to ensure our business logic works.
i.e. validations, calculations, sorting order, etc.
Unit Tests sits at the base of the Testing Pyramid. This means they take lesser time to code and classes that you are testing should be more isolated. For example, a Login Feature normally has Validation and
Authentication logic. They should be written in two separate classes like
LoginAuthenticator. Based on these two classes, you write test scripts.
When you try to test Networking functions, like in
LoginAuthenticator, you should use Mock Response to test for both positive and negative responses.
Integration Tests sits at the next level after Unit Tests. Here, you will use Real Network Responses, by hitting the real server endpoint, and test that the small units you have written are able to work together.
Interaction Tests help us to ensure our Application Interaction works by simulating them using native or third-party tools.
UI Testing automates repetitive tasks to ensure that your most critical UI interactions keep working as you’re adding new features or refactoring your app’s codebase. It may also help new developers to understand the app as they just need to run the UI Test once, he is able to see the…