# 主体程序
主体程序指的是被测试的程序,同时也是将来在项目中真正要使用的程序
package com.dkx.maven | |
public class Calculator{ | |
public int sum(int i,int j){ | |
return i + j; | |
} | |
} |
# 测试程序
package com.dkx.maven; | |
import org.junit.Test; | |
import static org.junit.Assert.*; | |
public class CalculatorTest{ | |
@Test | |
public void testSum() { | |
Calculator c = new Calculator(); | |
int s = c.sum(5,3); | |
System.out.println(s); | |
int a = 8; | |
assertEquals(a,s); | |
} | |
} |