public int subtract(int a, int b) {
return a - b;
}
public int multiply(int a,int b) {
return a * b;
}
public int divide(int a ,int b) {
return a / b;
}
}
CalculateTest测试代码
package com.cyt;
import static org.junit.Assert.*;
import org.junit.Test;
public class CalculateTest {
@Test
public void testAdd(){
assertEquals(6, new Calculate().add(3, 3));
}
@Test
public void testSubtract() {
assertEquals(3, new Calculate().subtract(5,2));
}
@Test
public void testMultiply() {
assertEquals(4, new Calculate().multiply(2, 2));
}
@Test
public void testDivide() {
assertEquals(3, new Calculate().divide(6, 2));
}
}