【问题标题】:White-Box Testing白盒测试
【发布时间】:2014-04-30 23:43:47
【问题描述】:

我只是想知道以下代码中的语句覆盖率/决策覆盖率/条件覆盖率之间有什么区别。

public static void main (String args [])

{    
char letter=' ';    
String word= "", vowels = "aeiouAEIOU";    
int i, numVowels= 0, numCons= 0, wordLength= 0;    
word = JOptionPane.showInputDialog("Input a word: " );    
if (word.length() > 10 || word.length() < 3)
   word = JOptionPane.showInputDialog("Input another word: ");    
wordLength= word.length();    
for (i = 0; i < wordLength; i++)    
   letter = word.charAt(i);    
   if (vowels.indexOf(letter) != -1)    
   numVowels = numVowels+1;    
numCons = wordLength-numVowels;    
JOptionPane.showMessageDialog(null, "Number of vowels: "+ numVowels);
JOptionPane.showMessageDialog(null, + " Consonants: " + numCons); 

}

附:任何 if 语句中都没有大括号。

【问题讨论】:

  • For 循环中应该有大括号。对吗?

标签: testing white-box-testing


【解决方案1】:

不同的工具使用稍微不同的术语来解释这些数字。对于 ex jacoco,使用以下术语 http://www.eclemma.org/jacoco/trunk/doc/counters.html

如果您能告诉我们您用于计算覆盖率的工具,这可能会有所帮助。然后我们可以将它应用到您的代码中

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多