Why tests?
Adding tests to your app provides a way to ensure that our app does what we expect of it. And not only do tests check that our code works they also offer an assurance that future changes won’t break existing features and bugs we’ve fixed in the past stay fixed.
Anatomy of tests
Tests come in two forms: tests that can be run automatically by a computer, and tests that require manual processes. Both are an important part of any app’s testing strategy, but it’s the automated side that is the main force behind our ability to make bold changes: In order of increasing complexity, they are:
1. unit tests
2. integration tests
3. user interface tests.
Recommended by LinkedIn
Unit tests
Unit testing forms the base and the foundation of all tests. They are the first tests you write, and the most useful tests to write. Generally speaking, each unit test ensures that you get the expected output when a function processes a given input. Multiple unit tests may test the same piece of code, but each unit test itself should only focus on a single unit of code.
Integration tests
On the next level, we have the integration tests, which verify how well different parts of our app work together, and how well our app is integrated with the world outside, such as against external APIs. Integration tests are more complex, they generally take longer to run, and as a result, you’ll run them less often.
User interface tests
At the top we have user interface tests or UI tests, these tests verify the user-facing behavior of our app. They simulate user interaction with the app and verify the user interface behaves as expected after responding to the interaction.
Conclusion
Each type of test checks a broader scope in the app. For example, a unit test would verify that for a given input methodA() returns the correct value. An integration test would check that your app is capable of calling an API and parsing the output. A UI test would make sure that after launching the app the correct screen is shown.