待测类(CreateString)如下:
public class CreateString { public void createString() { //Output the following string "1 2 3" System.out.print("1 2 3\n"); //Output the following string "1 2 3" System.out.print("1 "+"2 "+"3\n"); //Output the following string "1 2 3" System.out.print(new String("1 2 3\n")); //Output the following string "1 2 3" System.out.print(new String("1 2 3\n")); } } |
开始编写测试类(CreateStringTest)如下:
在CreateString.Java 文件上右键(或Ctrl+N),弹出下图:
选择 JUnit test case 或者 Test Suite,弹出下图: