标签:
package com.ss1.junit; public class Calculator { public int add(int one, int another) { // 为了简单起见,暂不考虑溢出等情况。 return one + another; } public int multiply(int one, int another) { // 为了简单起见,暂不考虑溢出等情况。 return one * another; } }
package com.ss1.junit; import static org.junit.Assert.*; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; public class CalculatorTest { private Calculator calculator; @Before public void setUp() throws Exception { calculator = new Calculator(); } /* @Test public void test() { fail("Not yet implemented"); } */ @Test public void testAdd() throws Exception{ int sum = calculator.add(1,2); assertEquals(3, sum); } @Test public void testMultipy() throws Exception{ int product = calculator.multiply(2,4); assertEquals(9, product); } @Test @Ignore("not implemented yet")//该方法未完成,跳过对此方法的验证 public void testIgnore() throws Exception{ } }
标签:
原文地址:http://www.cnblogs.com/tingbogiu/p/5753164.html