- QATestLab Blog >
- QA Basics >
- Coverage Techniques in Software Testing
Coverage Techniques in Software Testing
Note: this atricle was updated in July 2019.
How to cover everything with your attention and control? In software testing, we use test coverage to define the percent of executed tests. Test coverage is a measurement in Software Testing that shows the percentage of product functionality which is tested and defines the amount of the entire testing circle. It determines which branches of the program were examined and which conditions and setting were considered.
There are various possible paths between the initial and final stages of software application testing. Since there are rarely enough resources to test every path, a tester can use white-box logic coverage techniques to select the code coverage testing that is the most likely to help identify the yet undiscovered, relevant defect. Let`s reveal more about test coverage techniques.
How to Involve Coverage Technique
Test coverage finds requirements which are not included to test cases. It provides a quality check by measurement of the executed tests’ amount (unit test code coverage). Coverage helps to identify useless test cases which do not increase the testing productiveness and helps to create additional ones.
To choose the right coverage technique, it is important to consider the fact that there may be undiscovered defects which escaped the testing. A tester needs to define the potential impact of such a bug on the product functionality and predict its source. The type of test coverage should be chosen basing on the harm of possible undiscovered bug.
The minimum needed test coverage is statement coverage, path coverage, and decision coverage. If the part of the code is not tested, there is no opportunity to detect a bug during tests. The statement coverage plays a base for adding further, more complicated techniques.
The optimal way of providing the complete coverage is to make test case basing on each certain defect. Transformation of each independent bug into an element of a definite testing strategy increases the probability to avoid undiscovered defects.
Why Test Coverage is Valuable
- it prioritizes testing task;
- it prevents mismatch in requirements, provides coverage close to 100%;
- simplifies the analysis of impact;
- determines the EXIT criteria easily;
- simplifies test reporting;
- identifies which parts of the code were examined and fixed;
- shows the paths which were not tested;
- helps to monitor the expenses, time, efforts and prevents its unreasonable use;
- prevents defects and requirement gaps at early development stages.
Drawbacks:
- there are no tools for automation, so the most actions are manual;
- it costs much time and efforts for requirements and test case analysis;
- there is a probability of errors.
Calculation of Test Coverage
You need to perform the following steps to get the coverage formula:
- Firstly, consider all code lines which are under testing (marked as Y).
- Secondly, take the number of code lines from all test cases (marked as X).
- Finally, you have to divide X by Y and multiply the result by 100. After these simple calculations, you know the % of your test coverage
For example:
- There are 500 code lines.
- There are 50 code lines of executed test cases.
- As a result, the percent of coverage is defined as: (50 / 500) * 100 = 10%.
Test Coverage Techniques
There are several areas for test coverage which are essential to examine with the respective coverage techniques:
Product coverage
The scope of this technique is to monitor which parts are tested using test coverage tools, and which are still being not examined.
Example: The app must be capable to respond to the unusual actions of the user. It must be checked whether the multiple users can interact with a program at the same time. It is also important whether the application is able to function properly while other apps are opened on the same device. If at least one of these elements is not tested, it is impossible to define the testing as complete.
Risk coverage
You can not consider the product as completely tested if there was no examination of associated risks and their sources. Even if you ensure the proper work of a function, it is important to predict whether it is possible to face the failure in the future, how big the probability is, and what may be the potential reason of failure.
Example: Such app as e-commerce web site can be tested carefully, and each independent function can be completely verified. However, a tester can miss the question of simultaneous access of multiple users, which may cause failure even in case of successful interaction with each certain user.
Requirements coverage
This stage aims to define whether the developed product matches the expected requirements and is capable to perform its purpose.
Example: The subject of testing is a chat application, and each certain function works properly. But requirement documents specify that multiple users have to be able to interact with a program without failures, and this feature was not examined. In this case, we can not consider such a product as completely covered.
Compatibility coverage
It defines the integration of the program with different browsers and platforms. It shows the issues in cooperation with devices that have various settings and configurations.
Conclusion
It is not always right to think that the more tests are performed, the bigger is the probability of high quality. In fact, if you just test a lot but without a reliable strategy, it will only take the tons of time. That is why you need effective methods to check the execution and track the progress of reaching your goal, which is possible due to the coverage techniques. The right approach will allow you to ensure the proper direction of your testing and save your time and efforts.
QATestLab hopes that the described tips will become good point markers on your path to the expected end result.
Learn more from QATestLab
Related Posts:
- Software Development (Doesn’t) Need Independent QA
- Is Your E-commerce Ready for Black Friday & Cyber Monday? Let’s Check!
- Quality Assurance for Renewable Energy Software: How to Do It Right?