How to run JUnit tests with Gradle?

前端 未结 5 1197
野的像风
野的像风 2020-12-12 20:19

Currently I have the following build.gradle file:

apply plugin: \'java\'

sourceSets {
    main {
        java {
            srcDir \'src/model\'
           


        
5条回答
  •  北荒
    北荒 (楼主)
    2020-12-12 20:27

    If you created your project with Spring Initializr, everything should be configured correctly and all you need to do is run...

    ./gradlew clean test --info
    
    • Drop --info if you don't want to see test output.
    • Drop clean if you don't want to rerun tests that have already passed since the last change.

    Dependencies required in build.gradle for testing in Spring Boot...

    dependencies {
        compile('org.springframework.boot:spring-boot-starter')
        testCompile('org.springframework.boot:spring-boot-starter-test')
    }
    

    For some reason the test runner doesn't tell you this, but it produces an HTML report in build/reports/tests/test/index.html.

提交回复
热议问题