JUnit3

import junit.framework.TestCase;
import static org.junit.Assert.*;

public class SomeThingTest extends TestCase{
    SomeThing st=null;
    public void setUp() throws Exception{
        //在每个测试执行之前执行一次
        st=sss;
    }
    public void tearDown() throws Exception{
        //在每个测试执行之后执行一次
        st=null;
    }
    public void testST(){       //要以test开头
        int expResult=10;  //预期结果
        int result=st.getNum();  //实际结果
        assertEquals(expResult,result);  //断言相等
    }
}

  

原文地址:https://www.cnblogs.com/frostbelt/p/2282417.html