【问题标题】:From the following code, at least how many test cases are needed to guarantee 100% coverage?从下面的代码来看,至少需要多少个测试用例才能保证100%的覆盖率?
【发布时间】:2014-11-23 18:31:42
【问题描述】:
Input Number_of_Coins
Total=0
While Number_of_Coins > 0
Input Value_of_Coin
Total=Total + Value_of_Coin
Number_of_Coins=NUmber_of_Coins -1
End Loop
Print "Your coins are worth " & Total

3
1
4
2

据我说,答案是 3。

如果我的回答是正确的,请有人解释一下。

【问题讨论】:

    标签: testing code-coverage


    【解决方案1】:

    我会测试以下内容:

    1. Number of_Coins
    2. 硬币数量 = 1
    3. 硬币数量不是有效数字
    4. 硬币数量 > 1 并且所有 Value_of_coin 条目 > 0
    5. Value_of_coin 一个或多个条目是否定的
    6. Value_of_coin 一项不是有效数字
    7. Value_of_coin 条目少于 Number_of_coins
    8. Value_of_coin 条目比 Number_of_coins 更多

    我至少做到了 8 个 - 可能还有更多。

    【讨论】:

      【解决方案2】:

      但给出的选项是 1-4。我认为这个问题至少说明了测试用例。所以它应该是覆盖 100% 覆盖率的最低测试用例。

      【讨论】:

        猜你喜欢
        • 2020-07-28
        • 1970-01-01
        • 2023-03-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-12-14
        • 2017-10-09
        • 2017-02-21
        相关资源
        最近更新 更多