单元测试
是指对软件中的最小可测试单元进行检查和验证。
Junit单元测试
Junit是一个基于Java语言的单元测试框架。是白盒测试的一种技术。
Assert: 断言,给定预知的结果,判断程序运行结果是否符合。
@Before: 方法之前运行一次
@After: 方法之后运行一次
@BeforeClass: 测试类所有方法之前运行一次
@AfterClass: 测试类所有方法之后运行一次
测试类:
package jdbc.test;
import org.junit.*;
public class OperationTest {
private static Operation oper;
/* @Before
public void methodBefore(){
oper = new Operation();
System.out.println("测试方法之前");
}
@After
public void methodAfter(){
oper = new Operation();
System.out.println("测试方法之后");
}*/
@BeforeClass
public static void BeforeClass