내 테스트 경험은 주로 루비의 Rspec입니다. 그리고 최근에 자바 jUnit 테스트를 작성하려고했습니다. 여기에 예제가 있습니다. 그런 다음이 테스트가 필요한지 궁금해지기 시작했습니다. properties()
은 메서드 서명을 기반으로 Properties
또는 null
을 반환합니다. 그래서 메소드를 테스트하고 싶다면 반환 값이 null이 아닌지 테스트해야합니다.이 junit 테스트가 필요합니까?
public class HelperTest {
@Test
public void testProperties() {
assertThat(Helper.properties(), instanceOf(Properties.class));
}
}
public class Helper {
public static Properties properties() {
// ... some code to init properties ...
return properties;
}
}
'assertNotNull (...)'에 문제가 있습니까? – Bohemian
... 또는'assertThat (Helper.properties()). isNotNull()'? – fge
결코 실패하지 않는 테스트는 잘못된 보안 감각을 제공합니다. –