Why tests?
https://lawrey.medium.com/unit-tests-ui-tests-integration-tests-end-to-end-tests-c0d98e0218a6

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.

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.

To view or add a comment, sign in

More articles by AbdelAli J.

  • Which property wrapper for what purpose?

    In SwiftUI property wrappers are often overused even though they are powerful tools. A key principle is to use regular…

  • Leave your ego behind

    Ego is our sense of self-esteem that helps shape our identity and life goals. However an unchecked ego can lead to…

  • How I Interview Developers: A Simple Approach

    When I interview a developer I focus on three important questions: Are they smart? Can they get things done? Can We…

    1 Comment
  • The Power of Naming Conventions

    When SwiftUI 2 was released our team eagerly adopted it for our project. We jumped right in and enjoyed the excitement…

  • Understanding SwiftUI’s Observation Framework

    In SwiftUI observation tools like @Published and ObservableObject weren’t perfect. They often made us either watch too…

  • Swift Enums tips and tricks

    Swift enums are perhaps one of the most interesting features of the language. From defining a finite list of cases, to…

    1 Comment
  • Build, Test, & Deploy an iOS App with Github Actions (Part1)

    In his article, you'll learn how to automate the process of deploying your builds to testers using TestFlight. The Goal…

  • Encapsulate new SwiftUI APIs

    Apple’s SwiftUI framework is progressing at a rapid pace and as we support older versions of the operating system the…

  • How to handle errors in Swift

    Good error handling is one of those factors that distinguishes good applications from bad ones, yet we often tend to…

  • Unowned or Weak?

    When dealing with retain cycles we generally choose between unowned or weak attribute, but sometimes we could be still…

Others also viewed

Explore content categories