'Gradle'에 해당되는 글 1건

  1. 2017.10.11 JUnit 과 Mockito 에서 org.hamcrest 충돌문제

기존의 Maven 으로 작성된 프로젝트를 Gradle 로 변경하는 작업을 하였다.

자신있게 gradle build 를 했다.

그런데 Maven 으로 잘되던 것이 갑자기 test step 에서 error 가 나는것이다.

이유는 
import static org.hamcrest.CoreMatchers.containsString; 
에서 containsString 을 못찾는것이다.

이유를 찾아보니 
JUnit 에 종속적인 hamcrest 의 org.hamcrest 와 
org.mockito에 있는 org.hamcrest 가 충돌나는 것이었다.

정확한 해결책인지는 아직도 확신은 안들지만 
아래같은 순서로 [프로젝트네임].gradle 파일의 내용을 수정하니 잘되었다.

dependencies {  
  testCompile group: 'org.hamcrest', name: 'hamcrest-core', version: '1.3'
  testCompile group: 'org.mockito', name: 'mockito-all', version:'1.10.19'
  testCompile group: 'junit', name: 'junit', version:'4.12'
}

아마도 dependencies 하는 순서대로 호출시 참조하는 것 같다.

Posted by 빨강토끼
,