How to use JUnit and Hamcrest together?

前端 未结 8 962
傲寒
傲寒 2020-12-07 13:03

I can\'t understand how JUnit 4.8 should work with Hamcrest matchers. There are some matchers defined inside junit-4.8.jar in org.hamcrest.CoreMatchers. At the

8条回答
  •  春和景丽
    2020-12-07 13:42

    In 2018 using most modern libraries:

    configurations {
        all {
            testCompile.exclude group: "org.hamcrest", module: "hamcrest-core"
            testCompile.exclude group: "org.hamcrest", module: "hamcrest-library"
        }
    }
    dependencies {
        testCompile("junit:junit:4.12")
        // testCompile("org.hamcrest:hamcrest-library:1.3")
        // testCompile("org.hamcrest:java-hamcrest:2.0.0.0")
        testCompile("org.hamcrest:hamcrest-junit:2.0.0.0")
    }
    

提交回复
热议问题