JUnitファイル
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 ファイル
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;
}
Java ファイルif(c == null)
では、2 つのブランチのうち 1 つがカバーされていないというメッセージとともに黄色で強調表示されました。
throw new IllegalArgumentException();
強調表示された緑
insuredDAO.increaseValue(c);
この線の上と下はすべて赤です
私は何が欠けていますか?(JUnitテストは両方で合格しましたが、なぜカバーされていないのですか)?