It turns out that line coverage isn't such a great indicator of test effectiveness.
这表明行覆盖的确不能很好地指示测试的有效性。
The report in Figure 4 shows that I've achieved 75% line coverage and 100% branch coverage.
在图4的报告中显示我达到了 75% 的行覆盖率和 100% 的分支覆盖率。
There are different types of coverage measurements, but most tools focus on line coverage, also known as statement coverage.
存在不同类型的覆盖度量,但是绝大多数的工具会关注行覆盖,也叫做语句覆盖。
If a method is 10 lines long and 8 lines of the method were exercised in a test run, then the method has a line coverage of 80%.
如果一个方法有10行代码,其中的8行在测试中被执行,那么这个方法的行覆盖率是80%。
Non-executable lines such as comments are not annotated and do not contribute to the calculation of the line coverage percentage.
诸如评论之类的非执行行不会被注释,并不会对代码行覆盖率百分比的计算产生影响。
The process works at the aggregate level as well: If a class has 100 lines and 45 of them were touched, then the class has a line coverage of 45%.
这个过程在总体层次上也工作得很好:如果一个类有100行代码,其中的45行被触及,那么这个类的行覆盖率就是45%。
Just like line coverage, if there are two branches in a particular method and both were covered through tests, then you could say the method has 100% branch coverage.
与行覆盖一样,如果在特定方法中有两个分支,并且两个分支在测试中都被覆盖,那么您可以说这个方法有100%的分支覆盖率。
Likewise, if a code base comprises 10,000 non-commenting lines of code and 3,500 of them were exercised on a particular test run, then the code base's line coverage is 35%.
同样,如果一个代码库包含10000个非注释性的代码行,在特定的测试运行中有3500行被执行,那么这段代码的行覆盖率就是35%。
Line coverage: the percentage of lines covered in the class file.
行覆盖率:类文件中覆盖的行百分比。
Line coverage: the percentage of lines covered in the class file.
行覆盖率:类文件中覆盖的行百分比。
应用推荐