我只是想知道语句覆盖率/决策覆盖率/条件覆盖率与以下代码有什么不同。
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语句中都没有大括号。
发布于 2014-05-01 13:24:27
不同的工具使用略有不同的术语来解释这些数字。对于ex,使用以下术语http://www.eclemma.org/jacoco/trunk/doc/counters.html
如果您能告诉我们您正在使用的工具来计算覆盖率,这可能会有所帮助。然后,我们可以将其应用于您的代码
https://stackoverflow.com/questions/23399933
复制相似问题