1、修正流程图
2、测试用例设计
3、单元测试框架
import static org.junit.Assert.*; import org.junit.Before; import org.junit.Test; public class CommissionTest { Commission commission = new Commission(); @Before public void setUp() throws Exception { } @Test public void testMain() { assertEquals(29.2,commission.commission(2, 6, 9),0.0001); assertEquals(-1,commission.commission(-2,6,9),0.0001); assertEquals(161.8,commission.commission(16, 6, 9),0.0001); assertEquals(145.0,commission.commission(15, 6, 5),0.0001); assertEquals(405.2,commission.commission(30, 15, 22),0.0001); } }
4、测试结果
5、测试小结
单元测试可以很快的验证测试代码的正误,以后编写代码时要养成单元测试的习惯。
时间: 2024-10-08 23:45:08