Having an assertion somewhere in a method myMethod
in the production code like:
public void myMethod(List list1, List list2) {
assert list1.size() == list2.size()
}
and a unit test
@Rule
public ExpectedException ex = ExpectedException.none();
@Test
public void test() throws Exception {
ex.expect(java.lang.AssertionError.class);
myMethod(Arrays.asList(1, 2), Arrays.asList(1, 2, 3));
}
I expect the unit test to successfully run but I get the AssertionError
. Why is it so?