如何使用junit做单元测试?
答案很简单:搭好环境写好测试类,运行就可以了!但如果我有很多个测试类(方法),如何做到一次运行多个测试类呢?
首先创建个待测试的bean
package test;
public class testClass {
public static String sayHello(){
return "Hello";
}
然后创建junit测试类,如下:
注意必须继承TestCase类
package test;
import junit.framework.TestCase;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;