As we saw in earlier sections of this course, one of the stages in the software development process is testing. An it’s a really important stage. In this video you can see how important is to set up an appropriate and efficient test stage.
Software tests consist in the dynamic verification of the behavior of a program, with a properly selected set of test cases. Tests are performed in order to find possible bugs in the implementation, quality or usability of a given software.
The main targets of software testing are:
In order to reach these targets, software testing must follow a set of principles:
The stages of every testing process are:
Evaluating the results consists in comparing the actual test results with the expected results. Every difference between them means that there is a bug, and this bug is usually due to the unit or attribute that we are testing, although sometimes it can be due to the test process itself, if it hasn’t been properly run.
There are different types of tests. Let’s see them from lower to higher level.
Unit tests check the appropriate behavior of one code unit. A code unit is typically a class in object oriented languages (Java, C#…), or a set of functions closely related in non object-oriented languages (Python, JavaScript…). They are usually run by the development team, and they must be:
They try to find bugs in the interface connections and/or in the interaction between different components or units of an application. In other words, once the unit tests are successful, we try to join all (or some of) these units and see how the program works. They are performed by the development team by applying some of these techniques:
In this category we can also talk about regression tests. They consist in testing a given component whenever it has been modified, in order to find out any fault that was not previously checked. These faults can be found in either the modified code or in any other component integrated or related with the one that has been modified.
CI/CD
CI/CD stands for Continuous Integration / Continuous Deployment. It goes one step further after continuous integration and, if all the tests have been passed, then the application is automatically deployed on its target environment. Actually, we can distinguish between:
We are not going to delve into these aspects here, since they depend on the project architecture itself. CI/CD can be completely different depending on the operating system, IDE and language that we are using, so there are no commong guidelines that we can learn in this stage.
After the unit and integration stages, we can still differentiate two additional types of tests:
When we want to do any test over an application, we need to design the test cases. As we have said before, they are a set of conditions that can determine if software runs properly or not. The concrete definition according to the ISTQB (International Software Testing Qualifications Board) is: “a set of input values, execution preconditions, expected results and execution postconditions, developed for a particular objective or test condition, such as to exercise a particular program path or to verify compliance with a specific requirement”.
There are several formats for these test cases, but we must include the following data anyway:
Example:
We want to check the behavior of a given form to log in an application. These are some of the test cases that we could specify:
ID | Name | Preconditions | Steps | Data | Expected result | Actual result |
---|---|---|---|---|---|---|
U1 | ValidInput1 | User pepe exists with password 1234 | Type user and password | pepe 1234 | OK | |
U2 | UserNotValid | User pepito does not exist | Type user and password | pepito 1234 | error | |
U3 | PasswordNotValid | User pepe exists with password different than 4567 | Type user and password | pepe 4567 | error | |
… |
Exercise 1:
Design test cases to check the behavior of a function that returns a boolean indicating if the number specified as a parameter is even or not.