TextForfogit

caculator
package com.example.liuy.textforforgit;

/**
* Created by liuY on 2017/3/13.
*/

public class caculator {
public double sum(double a,double b){
return a+b;
}

public double substract(double a,double b) {
return a-b;
}
public double divide(double a,double b){
return a/b;
}
public double multiply(double a,double b){
return a*b;
}
}
caculatorText
package com.example.liuy.textforforgit;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.*;

/**
* Created by liuY on 2017/3/13.
*/
public class caculatorTest {


private caculator mcaculator;
@Before
public void setUp() throws Exception {
mcaculator=new caculator();
}
@After
public void tearDown() throws Exception {

}

@Test
public void sum() throws Exception {
assertEquals(20d,mcaculator.sum(10d,10d),0);


}

@Test
public void substract() throws Exception {
assertEquals(1d,mcaculator.substract(5d,4d),0);

}

@Test
public void divide() throws Exception {
assertEquals(4d,mcaculator.divide(20d,5d),0);

}

@Test
public void multiply() throws Exception {
assertEquals(100d,mcaculator.multiply(50d,2d),0);

}



}


原文地址:https://www.cnblogs.com/u1118746/p/6561894.html