JUnit file
public class SomeClassTest {
...
@Test
public void testSomeContextFailure() throws Exception {
SomeClass sc = new SomeClass();
try {
sc.SomeContext(null,null);
fail("IllegalArg expected");
} catch (IllegalArgumentException e) {}
}
@Test
public void testSomeContextSuccess() throws Exception {
SomeClass sc = new SomeClass();
SomeContext in = new SomeContext();
in.setName("something");
in.setId("5");
in.setPoints(SomePoint.X);
try {
assertNotNull(sc.SomeContext(in,null));
} catch (Exception e) {}
}
}
Java File
public class SomeClassTest {
@Autowired(required = true)
private InsuredDAO insuredDAO;
@Override
public context SomeContext(context c, unused u) throws Exception {
if(c == null)
throw new IllegalArgumentException();
insuredDAO.increaseValue(c);
if(c.getPoints() != null) {
...do something
}
return c;
}
In java file if(c == null)
was highlighted yellow with message saying 1 of 2 branches not covered.
throw new IllegalArgumentException();
highlighted green
insuredDAO.increaseValue(c);
Everything on and below this line is red
What am I missing? (JUnit test was passed on both but why it isn't covered)?