标签:
Calculate.java
package net.oschina.bairrfhoinn.main; public class Calculator { public void add(int n){ result += n; } public void substract(int n){ result -= n; } public void multiply(int n){ result *= n; } public void divide(int n){ result /= n; } public void square(int n){ result = n * n; } public int getReuslt(){ return result; } public void clear(){ result = 0; } private static int result; }
TestCalculate.java
package net.oschina.bairrfhoinn.test; import static org.junit.Assert.*; import org.junit.Test; import net.oschina.bairrfhoinn.main.Calculator; public class CalculatorTest { private static Calculator calculator = new Calculator(); @Test public void testAdd(){ calculator.add(7); calculator.add(8); assertEquals(15, calculator.getReuslt()); } }
标签:
原文地址:http://www.cnblogs.com/emma-0504/p/4809150.html