简单Junit测试代码
package test;
public class jbulder {
public int abs(int n){
return n>=0 ? n: (-n);
}
public static void main(String[] args){
}
}
package test;
import junit.framework.TestCase;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class JbulderTest extends TestCase{
private jbulder bulder;
@Before
public void setUp() throws Exception {
super.setUp();
bulder = new jbulder();
}
@After
public void tearDown() throws Exception {
super.tearDown();
}
@Test
public void testAbs() {
assertEquals(bulder.abs(14),14);
assertEquals(bulder.abs(-6),6);
assertEquals(bulder.abs(0),0);
}
}