如何在switch语句中获得100%的块覆盖率? [英] How to get 100% block coverage in switch statement?

查看:817
本文介绍了如何在switch语句中获得100%的块覆盖率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有句子都被执行​​,所有案件都是蓝色的。
但是swtich是黄色的。

All the sentences were executed and All the cases were blue. But swtich were yellow.

所有条件已经从测试代码中得到满足,但覆盖范围不是100%

请告诉我如何覆盖率达到100% 。

推荐答案

Hi SongIPark,

Hi SongIPark,

获得100%的代码覆盖率切换语句的情况,请记得在switch语句中添加一个我们不会处理的新值。

To get 100% code coverage of switch statement case, please remember to add a new value which we will not handle in the switch statement.

  例如,我们可以添加新值"无"在我们的测试用例中没有处理switch语句中的新值。

 For example, we could add a new value "None" in our test case without handling the new value in the switch statement.

我希望你明白这个主意。

I hope you get the idea.

但如果有可能,欢迎您在此处发布您的代码,我们会尽力帮助您。

But you are welcome to post your code here if it’s possible, and we will try our best to help you out.

致以愉快的问候,

Fletch


这篇关于如何在switch语句中获得100%的块覆盖率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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