在JUnit中,要忽略测试,只需在@Test
方法之前或之后添加@Ignore
批注。
PS已通过JUnit 4.12测试
IgnoreTest.java
package com.mkyong;
import org.junit.Ignore;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
public class IgnoreTest {
@Test
public void testMath1() {
assertThat(1 + 1, is(2));
}
@Ignore
@Test
public void testMath2() {
assertThat(1 + 2, is(5));
}
@Ignore("some one please create a test for Math3!")
@Test
public void testMath3() {
//...
}
}