Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

It's important to talk about the goal of testing. While it's significant to test that users can use your application (I can log in, I can save an object) it is equally important to test that your system doesn't break when incorrect data or unexpected actions are performed. You need to anticipate what would happen when a user makes a typo, tries to save an incomplete form, or uses the wrong API. You need to check if someone can easily compromise data, get access to a resource they're not supposed to. A good testing suite should try to break your app and help understand its limit.

There are many different types of testing that you can use to make sure that changes to your code are working as expected. Not all testing is equal, though, and we will see here how the main testing practices differ from each other.

Pros and cons of testing

Pros:

  • More reusable code and easier debugging.
  • Reduce the cost of bug-fixing.
  • Errors can be detected at the early stages.
  • Increased efficiency of code improvement and maintenance.
  • Tests help find problems and resolve them.

Cons:

  • The process of testing can be time-consuming.
  • Not all errors can be detected.


Manual vs. automated testing

At a high level, we need to make the distinction between manual and automated tests. Manual testing is done in person, by clicking through the application or interacting with the software and APIs with the appropriate tooling. This is very expensive as it requires someone to set up an environment and execute the tests themselves, and it can be prone to human error as the tester might make typos or omit steps in the test script.

Automated tests, on the other hand, are performed by a machine that executes a test script that has been written in advance. These tests can vary a lot in complexity, from checking a single method in a class to making sure that performing a sequence of complex actions in the UI leads to the same results. It's much more robust and reliable than automated tests – but the quality of your automated tests depends on how well your test scripts have been written.

Automated testing is a key component of continuous integration and continuous delivery and it's a great way to scale your QA process as you add new features to your application. But there's still value in doing some manual testing with what is called exploratory testing as we will see in this guide.


Unit vs Integration tests

Unit tests are very low level, close to the source of your application. They consist of testing individual methods and functions of the classes, components or modules used by your software. Unit tests are in general quite cheap to automate and can be run very quickly by a continuous integration server.

Integration tests verify that different modules or services used by your application work well together. For example, it can be testing the interaction with the database or making sure that microservices work together as expected. These types of tests are more expensive to run as they require multiple parts of the application to be up and running.