사용자 도구

사이트 도구


java:junit:hamcrest

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
java:junit:hamcrest [2012/01/17 01:29]
kwon37xi
java:junit:hamcrest [2015/11/23 20:05] (현재)
kwon37xi [의존성]
줄 1: 줄 1:
 ====== hamcrest ====== ====== hamcrest ======
-  * http://code.google.com/p/hamcrest/+  * http://hamcrest.org/ : 원래 Java용이었으나 다양한 언어로 만들어짐. 
 +  * [[http://www.javacodegeeks.com/2015/11/hamcrest-matchers-tutorial.html|Hamcrest matchers tutorial]] 
 +  * [[http://www.javacodegeeks.com/2015/11/custom-hamcrest-matchers.html|Custom Hamcrest Matchers]] 
 + 
 +===== 의존성 ===== 
 +  * 의존성을 걸때는 최소한 ''hamcrest-core''와 ''hamcrest-library''를 함께 걸어줘야 충분한 Matcher들을 확보할 수 있다. 
 +  * 그렇지 않으면 한번에 ''hamcrest-all''에 걸어준다.
  
 ===== hasProperty ===== ===== hasProperty =====
줄 7: 줄 13:
   * 단일 객체 비교<code java>   * 단일 객체 비교<code java>
 User user = new User("이하늬", 20, "몰라"); // name, age, description User user = new User("이하늬", 20, "몰라"); // name, age, description
-assertThat(user, Matchers.<User>hasProperty("name", is("이하늬"))); 
- 
-user = new User(null, 20, "몰라"); // name, age, description 
  
 // 테스트 결과 Matchers.<Type>hasProperty(..) 형태로 사용해야만 제대로 작동했다. // 테스트 결과 Matchers.<Type>hasProperty(..) 형태로 사용해야만 제대로 작동했다.
 +assertThat(user, Matchers.<User>hasProperty("name", is("이하늬")));
  
 +user = new User(null, 20, "몰라"); // name, age, description
 assertThat(user, Matchers.<User>hasProperty("name", nullValue())); assertThat(user, Matchers.<User>hasProperty("name", nullValue()));
 </code> </code>
java/junit/hamcrest.1326731351.txt.gz · 마지막으로 수정됨: 2012/01/17 01:29 저자 kwon37xi