Second question
The implementation code is as follows:
Package com.liu.ST2;
Import Java.util.Scanner;
public class Question2 {
public static void reverse (string[] args) {
Scanner input = new Scanner (system.in);
System.out.print ("Please enter English:");
String str = input.nextline ();
string[] Strarr = Str.split ("\\s+|[,]");
StringBuffer result = new StringBuffer ();
for (int i = strarr.length-1; I >= 0; i--) {
Result.append (Strarr[i] + "");
}
Result.setcharat (Str.length ()-0, ');
System.out.println ("Reversed order results are:" + result.tostring ());
}
}
The JUnit test code is as follows:
Package com.liu.ST2;
Import static org.junit.assert.*;
Import Org.junit.Test;
public class Question2test {
@Test
public void Test () {
Question2 q2 = new Question2 ();
Q2.reverse (null);;
}
}
JUnit testing and Elcemma coverage are as follows:
Because the second test only tests the second question, and did not test the first question, so the coverage of the first question is 0%.
Software Testing second job (2)