mockito, junit, Hamcrest maven dependency 이용시 va.lang.NoSuchMethodError: org/hamcrest/Matcher.describeMismatch 처리 방법


출처 

http://tedvinke.wordpress.com/2013/12/17/mixing-junit-hamcrest-and-mockito-explaining-nosuchmethoderror/



mockito-core-1.9.5와 JUnit 4.11은 각각 내부적으로 의존관계(transitive dependency) 를 가지고 있는 Hamcresto-core 버전이 다르기 때문에 이슈가 된다. 다음과 같이 hamcrest-core 를 exclude 시키고 hamcrest-all을 따로 include 한다. 


<dependency>

    <groupId>org.mockito</groupId>

    <artifactId>mockito-core</artifactId>

    <version>1.9.5</version>

    <exclusions>

        <exclusion>

            <artifactId>hamcrest-core</artifactId>

            <groupId>org.hamcrest</groupId>

        </exclusion>

    </exclusions>

</dependency>

<dependency>

    <groupId>junit</groupId>

    <artifactId>junit</artifactId>

    <version>4.11</version>

    <exclusions>

        <exclusion>

            <artifactId>hamcrest-core</artifactId>

            <groupId>org.hamcrest</groupId>

        </exclusion>

    </exclusions>

</dependency>

<dependency>

    <groupId>org.hamcrest</groupId>

    <artifactId>hamcrest-all</artifactId>

    <version>1.3</version>

</dependency>






Posted by '김용환'
,