Test Coverage Rate-test coverage rate Classification

Source: Internet
Author: User

Original article published on 23:10:11

Regarding coverage, the two most common terms on the network should be"Rate "(TestCoverage) and"Code coverageRate "(code coverage ). Let's explore these two things today.
In the test, the test coverage is generally divided into two parts: "requirement coverage" and "code coverage". As you can see, the code coverage rate is actually part of the test coverage rate. Among them, the most common discussion and concern is "code coverage", code coverage is divided into program statements and code line coverage,Branch coverageAndConditional coverage. We will explain these concepts one by one.
Requirement coverage rate: if the requirement has been defined, we need to consider the requirement coverage rate at this time. At this time, you must note that the requirements here are not only functional requirements, but also performance requirements. The most intuitive way to measure the requirement coverage is how many features we have, how many performance requirements we have, and how many modules we have written as the denominator, how many features, ourPerformance TestingThe use case considers the number of performance points of the program to be tested as molecules.
Code coverage: for more comprehensive coverage, we may also need to test the program process. We may consider the data input and output of a function, or even the execution of each line of code, every logic and branch of the Code. At this time, the test execution is measured by the code coverage rate.Unit TestThe coverage rate.
Statement OverwriteRate: change the name to "code line coverage", which means to monitor whether each line of code is executed in the use case (of course all, to be precise, we have executed about of the statements/code lines in the use case. Note that even if all statements are executed, they are not necessarily executed in all paths. For example, there are five statements: ABCDE. If we execute the use case to overwrite ABCDE, and in another use case, We overwrite all the statements, but a path (such as ABC) may not be executed, for example:
Public verifytoken (string yourname, string yourtitle)
{
A output ("hello, my dear friends");
B if (yourname = "uniquestudiowcd ")
{
C output ("Hello, Aaron ");
}
D if (yourtitle = "tester ")
{
E output ("hello, my dear tester ");
}
}
At this time, we input the parameters uniquestudiowcd and tester to overwrite all the statements, but we missed a path: Enter the parameters uniquestudiowcd and coder.
Branch coverage rate: We also change the name"Path OverwriteRate ", although not completely correct. In the above example, if we only consider the first case (that is, the input parameters "uniquestudiowcd" and "tester"), our statement coverage rate is 100%, and the belt path coverage rate is lower, because it has many paths such as abd, ABCD, ABCDE, and abde.
Conditional coverage: This is why "branch coverage" is different from "path coverage. If we add a judgment combination to an if statement, we need to consider more problems, because it mainly appears in the Condition Statement, so we call it "Conditional overwrite". Let's change the above sample code:
Public verifytoken (string yourname, string yourtitle, string gendar)
{
A output ("hello, my dear friends");
B if (yourname = "uniquestudiowcd" & gendar = "man")
{
C output ("Hello, Aaron ");
}
D if (yourtitle = "tester ")
{
E output ("hello, my dear tester ");
}
}
Obviously, even if we enter the parameters "uniquestudiowcd" "tester", "woman" and "uniquestudiowcd" "tester" "man", the paths of these two cases are the same, but the conditional coverage is different. In fact, the "paths" of the two are different.
Some basic knowledge about test coverage rate is introduced above. In the second article about test coverage rate, "test coverage rate 2-what is the purpose of test coverage rate, I will introduce the usefulness of the test coverage rate, or the significance of the test coverage rate.
Personal opinion, for reference only ~ If you have any questions, please contact unique.wuchaodong@hotmail.comTestOverwrite

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.