运行 Spring 在单独的 gradle 任务中进行云合同测试

Running Spring cloud contract test in separate gradle task

我想 运行 spring 云合同测试用例作为名为 "asyncContractTestCases" 的单独 gradle 任务的一部分 我已经配置合同任务如下:

contracts { 
       generatedTestSourcesDir = project.file('src/contracttest/async/provider/java')
       basePackageForTests='com.test.producer'
       baseClassForTests="com.test.producer.MessagingContractTests"
   }

并创建了一个单独的 gradle 任务来执行这些测试用例,但这些测试用例仍然与 gradle 测试一起执行(作为 JUNITS 的一部分)。如何不 运行 spring 云合同测试用例作为 junits 的一部分?

您可以更改 Gradle 测试执行的配置。您可以默认排除合同测试并将其包含在您的任务中

test {
    description = "Task to run unit and integration tests"
    testLogging {
        exceptionFormat = 'full'
    }
    exclude '**/producer/**'
}

task asyncContractTestCases(type: Test) {
    description = "Task to run contract tests"
    testLogging {
        exceptionFormat = 'full'
    }
    include '**/producer/**'
}