Skip to main content

[JUnit] JUnitMatchers 변경사항. - JUnit in Action

JUnit 에서 많이 사용하는 Hamcrest 라이브러리는 현재 1.3 버전이 가장 최신인다.
책에서는 JUnit 4.6 을 사용하기 때문에 Hamcrest 를 포함하고 있지만. 4.11 부터는 별도로 hamcrest-core.jar 를 다운 받아야 한다.

예제 3.18 에서는 hasItem 메소드를 사용하기 위해 다음과 같이 import 를 진행 한다.

import static org.junit.JUnitMatchers.hasItem;

그런데 실제 코드에서 해당 메소드를 사용하게 되면 deprecated 표시가 나타나게 된다.

JUnit sorce code  에서 JUnitMacthers.java 를 살펴보면 아래와 같은 주석을 보게 된다.

Convenience import class: these are useful matchers for use with the assertThat method, but they are not currently included in the basic CoreMatchers class from hamcrest.

또한 대부분의 method 가 Deprecated 되어 있다. 그 대신, CoreMatchers 의 메소드 를 사용하라고 권고 하고 있다.

org.hamcrest.CoreMatchers 를 살펴보면 JUnitMatchers 가 가지고 있던 메소드를 동일하게 가지고 있다.




Comments

Popular posts from this blog

[Android Application Testing Guide] Chapter3 jar file

Android Application Testing Guide(에이콘) 3장 Sample 을 실행시키기 위해서는 libdummy-0.0.1.jar 가 필요한데, sample file 에는 프로젝트만 존재한다. 결국 jar 를 만들어야 되는데.. ant 빌드다. 어허허... jar 파일이 없으면 예제 진행이 어려우므로. ant build 한 jar 를 첨부. libdummy-0.0.1.jar download

[번역] A journey on the Android Main Thread - Part 1

본 문서는 square engineering blog 에 기재된 A journey on the Android Main Thread - Part 1 기사를 번역한 것 입니다. coding horrer 에 왜 우리는 소스 읽는 법 을 배워야 하는가 에 대한 기사 가 있습니다. 안드로이드의 가장 큰 특징 중 하나는 오픈소스 생태계 라는 점 입니다. PSVM (public static void main) public class BigBang {   public static void main ( String ... args ) {     // The Java universe starts here.   } } 모든 자바 프로그램은 public static void main() 메소드를 호출하면서 시작합니다. 이는 자바 데스크탑 프로그램, JEE 서블릿 컨테이너, 안드로이드 애플리케이션 이 모두 동일 합니다. 안드로이드 시스템은 부팅 단계에서 ZygoyteInit 이라 불리는 리눅스 프로세스를 실행합니다. 이 프로세스는 달빅VM 으로, 쓰레드에 안드로이드 SDK 의 대부분의 클래스 를 로드 하고 대기합니다. 새로운 안드로이드 애플리케이션을 시작할 때, 안드로이드 시스템은 ZygoteInit 프로세스를 포크 하게 됩니다. 포크된 자식 프로세스의 쓰레드는 대기를 해제하고, ActivityThread.main() 메소드를 호출합니다. 위키피디아 에 정의된 zygote 란 수정란을 의미합니다. Loopers 계속 진행하기 앞서, 우리는 Looper (이하 루퍼) 클래스를 살펴 볼 필요가 있습니다. 루퍼를 사용하는 것은 하나의 쓰레드가 메시지들을 연속해서 실행하도록 하는 좋은 방법 입니다. 각각의 루퍼는 메시지 객체의 큐를 지니고 있습니다. (이를 메시지 큐 MessageQueue 라고 합니다.) 루퍼는...

[Cobertura] cobertura 2.0.2 script fix

cobertura 2.0.2 버전을 다운받고 실행 시키려고 하면 엄청난 에러가 뿜어져 나온다. ㅠ 달리 설정을 틀리게 한 것도 없는데.. 하면서 script 를 열어보니 아래와 같이 작성되어 있다. - cobertura-instrument.sh java -cp `dirname $0`/cobertura.jar:`dirname $0`/lib/asm-3.3.1.jar:`dirname $0`/lib/asm-tree-3.3.1.jar:`dirname $0`/lib/asm-commons-3.3.1.jar:`dirname $0`/lib/log4j-1.2.9.jar:`dirname $0`/lib/jakarta-oro-2.0.8.jar net.sourceforge.cobertura.instrument.Main $* - cobertura-instrument.bat java -cp "%COBERTURA_HOME%cobertura.jar;%COBERTURA_HOME%lib\asm-3.3.1.jar;%COBERTURA_HOME%lib\asm-tree-3.3.1.jar;%COBERTURA_HOME%lib\asm-commons-3.3.1.jar;%COBERTURA_HOME%lib\log4j-1.2.9.jar;%COBERTURA_HOME%lib\jakarta-oro-2.0.8.jar" net.sourceforge.cobertura.instrument.Main %CMD_LINE_ARGS% 그런데 막상 다운받은 folder 구조를 보면.. cobertura-2.0.2.jar /lib     - asm-4.1.jar     - asm-commons-4.1.jar     - sam-tree-4.1.jar     - oro-2.0.8.jar .... script 왜 이렇게 되있지... 결국 cobertura 를 실행 시키기 위해서는 script 에서 버전 및 파일명을 다운받은 폴더...