JUNIT3 方法名必须以test开头
JUNIT4 使用标注就不用写test
为什么
package junit4;import org.junit.Test;
import junit.framework.TestCase;public class CalcTest extends TestCase {
private int x = 1;
private int y = 1;
@Test public void additionTest() {
int z = x + y;
assertEquals(2, z);
}
}却不行..
JUNIT4 使用标注就不用写test
为什么
package junit4;import org.junit.Test;
import junit.framework.TestCase;public class CalcTest extends TestCase {
private int x = 1;
private int y = 1;
@Test public void additionTest() {
int z = x + y;
assertEquals(2, z);
}
}却不行..
这里不行因为你junit3和junit4混用了吧assertEquals应该要用junit4的
import junit.framework.Assert;import org.junit.Test;public class CalcTest {
private int x = 1; private int y = 1; @Test
public void additionTest() {
int z = x + y;
Assert.assertEquals(2, z);
}}Junit3import junit.framework.Assert;
import junit.framework.TestCase;public class CalcTest extends TestCase{
private int x = 1; private int y = 1; public void testAddition() {
int z = x + y;
Assert.assertEquals(2, z);
}}