我跑在我的Eclipse下面的测试(带参数-ea):为什么我的Junit-AssertionError-Test失败?
public class ColorHelperTest
{
@Rule
public ExpectedException thrown = ExpectedException.none();
@Test
public void testGetColorByString()
{
thrown.expect(AssertionError.class);
assert 1 == 2;
}
}
输出是:
java.lang.AssertionError
at de.*.*.*.mytests.ColorHelperTest.testGetColorByString(ColorHelperTest.java:28)
28是行assert 1==2
为什么这个测试失败?
谢谢,这回答我的问题。惭愧...... –