在角度2的单元测试中询问“覆盖范围摘要"吗? [英] Asking about the Coverage summary in Unit test of angular 2?

查看:96
本文介绍了在角度2的单元测试中询问“覆盖范围摘要"吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在角度2中运行测试时,在覆盖率摘要"部分的控制台命令上看到一些关键字输出为StatementsBranchesFunctions....

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....

我不知道到底是什么吗?

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?

      功能:您声明的功能.

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

      SomeClass有两种方法,但是只有一种正在接受测试. 50%.如果您在测试中明确呼叫methodTwo methodOne呼叫methodTwo,则覆盖率达到100%

      SomeClass has two methods, but only one is getting tested. 50%. If you either explicitly call methodTwo in your test or methodOne calls methodTwo, your coverage goes to 100%

      行::代码行,检查是否所有代码行都被命中.

      Lines:: The lines of code, checks to see if all the lines of code are being hit.

      这篇关于在角度2的单元测试中询问“覆盖范围摘要"吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆