I have an application (Spring 4 MVC+Hibernate+jpa4+MySQL+Maven integration example using annotations) , integrating Spring with Hibernate using annotation based configuration.
and this unit test
@Test
public void testFindAll() throws Exception {
List<Guardian> guardians = getGuardianAccessorService().findAll();
assertNotNull (guardians);
assertTrue (guardians.size()>=0);
}
@Test
public void testFindCompanyGuardians() throws Exception {
List<Guardian> allGuardians = getGuardianAccessorService().findAll();
List<Guardian> guardiansByCompany = getGuardianAccessorService().findCompanyGuardians(AUTHENTICATED_USERNAME);
assertTrue (guardiansByCompany.size() <= allGuardians.size());
}
but in this asserts lines I have the warning 1 of 2 branches missed
assertTrue (guardians.size()>=0);
assertTrue (guardiansByCompany.size() <= allGuardians.size());
Not sure if it makes sense to actually run branch (or line) coverage on your unit tests. You should mainly inspect your target under test, not the tests. It is expected that if your tests do not fail that the fail brach is not taken, and this is reported as partial coverage.