How to use JUnit 5 with Gradle?

前端 未结 6 1600
长发绾君心
长发绾君心 2020-12-02 14:16

I am trying to use JUnit 5 with Gradle after I succeeded in running a JUnit 4 test.

Expected result: Tthe JUnit 4 test gave a nice \'passed\' in the

6条回答
  •  抹茶落季
    2020-12-02 14:52

    Maybe something helpful for those who were struck with this problem when trying to integrate JUnit5 with gradle version 4.10.

    Could not find method test() for arguments [build_dzas89s5z18l3bfyn6b3q0dxv$_run_closure2$_closure9@8e60c6] on project ':app' of type org.gradle.api.Project.
    

    Actually, with 4.10 you don't need to add this test configuration block in build.gradle to enable JUnit5.

    test {
        useJUnitPlatform()
    }
    

    It should work fine just by adding the necessary dependencies of jupitor-api and jupitor-engine.

    I tried to explore release notes of 4.10 but couldn't find anything about this change. If someone knows more about the "Why" behind it then please englighten me as well.

提交回复
热议问题