简体   繁体   English

在角度2的单元测试中询问覆盖率摘要?

[英]Asking about the Coverage summary in Unit test of angular 2?

When I run test in angular 2 and I see a few keywords output on console command in Coverage Summary section as Statements , Branches , Functions .... 当我在角度2中运行测试时,我在Coverage Summary部分的控制台命令上看到一些关键字输出作为StatementsBranchesFunctions ....

在此输入图像描述

And I don't know exactly what is it? 我不确切知道它到底是什么?

Any help explain this for me, thank you. 任何帮助都为我解释一下,谢谢。

  • Statement : I think this article does a pretty goo d job explaining what a statement it. 声明 :我认为这篇文章做了一个非常好的工作,解释它是什么声明。 The coverage tests that all your statements are getting hit. 覆盖测试表明您的所有陈述都受到了影响。

  • Branch : When you use conditionals it create branches 分支 :当您使用条件时,它会创建分支

     if (condition) { doThis(); // this is a branch } else { doThat(); // this is a branch } 

    Is your testing hitting all the branches? 你的测试是否打到了所有分支?

  • Functions : The functions that you declare. 功能 :您声明的功能。

     class SomeClas { methodOne() {} methodTwo() {} } it('..', () => { new SomeClass().methodOne(); }) 

    SomeClass has two methods, but only one is getting tested. SomeClass有两种方法,但只有一种方法正在接受测试。 50%. 50%。 If you either explicitly call methodTwo in your test or methodOne calls methodTwo , your coverage goes to 100% 如果你明确地调用methodTwo在您的测试 methodOne来电methodTwo ,你的覆盖面达到100%

  • Lines: : The lines of code, checks to see if all the lines of code are being hit. Lines ::代码行,检查是否所有代码行都被命中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM