We can categorize the types of tests we can create based on the target of the test:
- Unit Testing: The test target is a function or a class. The goal is to test that unit independently. Usually, we rely on an API interface in Unit Tests.
- Integration or System Testing: The test target is a whole system. The goal is to verify the end-user functionality of the system. There are multiple types of interfaces, and they will impact how the integration tests run. An interface could be Web API, User Interface, or file I/O.
We can also categorize tests base don their goal:
- Functional Test: The goal of this type of test is to verify one or more features or functionalities of the target.
- Performance Test: In a performance test, instead of verifying the result of the scenario being run, we verify the latency of execution, the CPU usage, and the memory usage of the target.
- Load Test: In a load test, we verify that the code or the system under testing can handle a certain amount of load. For example, if you are testing a web service, you want to see how the service will handle a certain number of concurrent requests. You aim to verify performance metrics such as response latency and CPU and memory usage. You can also verify things such as the integrity of the database and some measure of correctness of the responses.
- Security Test: in that type of test, you try to verify that the public interface of your unit or system can handle security risks. This usually involves sending malicious requests to probe for things such as weak login, buffer overrun, and other types of security vulnerabilities.
You need most of these test types in any system you build. As the system and the team gets bigger, the size and diversity of the tests you have will grow as well. One of the surprises many fresh engineers get is that they spend most of their time on different forms of testing. Most commercial development systems provide testing capabilities suitable for single developers and small teams. Many larger companies hire software engineers for the sole role of designing and building testing systems.