spring-cloud-contract
spring-cloud-contract copied to clipboard
Spring project with Cloud Contract and PACT not auto-generating the Provider test class
Describe the bug
Started a new Spring Gradle project from spring: Gradle/Java17/Spring Web/Spring cloud contract provider.
Created Pact Broker server locally. Added a "Consumer" test.
Configured Contracts to have PACT Broker server.
Running ./gradlew contractTest downloads the JSON but no auto-generated classes in the $build folder.
Using the ./gradlew contractTest -d (for debug logs) I can see that there are some messages from the ContractFileScanner:
2022-05-04T12:19:22.263-0300 [DEBUG] [org.gradle.api.Task] 12:19:22.235 [main] DEBUG org.springframework.cloud.contract.verifier.file.ContractFileScanner - File [$file] wasn't ignored but no converter was applicable. The file is a directory [${file.isDirectory()}]
12:19:22.236 [main] DEBUG org.springframework.cloud.contract.verifier.file.ContractFileScanner - File [$file] wasn't ignored but no converter was applicable. The file is a directory [${file.isDirectory()}]
12:19:22.237 [main] DEBUG org.springframework.cloud.contract.verifier.file.ContractFileScanner - File [$file] wasn't ignored but no converter was applicable. The file is a directory [${file.isDirectory()}]
12:19:22.237 [main] DEBUG org.springframework.cloud.contract.verifier.file.ContractFileScanner - File [$file] wasn't ignored but no converter was applicable. The file is a directory [${file.isDirectory()}]
12:19:22.237 [main] DEBUG org.springframework.cloud.contract.verifier.file.ContractFileScanner - File [$file] wasn't ignored but no converter was applicable. The file is a directory [${file.isDirectory()}]
12:19:22.237 [main] DEBUG org.springframework.cloud.contract.verifier.file.ContractFileScanner - File [$file] wasn't ignored but no converter was applicable. The file is a directory [${file.isDirectory()}]
12:19:22.237 [main] DEBUG org.springframework.cloud.contract.verifier.file.ContractFileScanner - File [$file] wasn't ignored but no converter was applicable. The file is a directory [${file.isDirectory()}]
12:19:22.237 [main] DEBUG org.springframework.cloud.contract.verifier.file.ContractFileScanner - File [$file] wasn't ignored but no converter was applicable. The file is a directory [${file.isDirectory()}]
12:19:22.237 [main] DEBUG org.springframework.cloud.contract.verifier.file.ContractFileScanner - File [$file] wasn't ignored but no converter was applicable. The file is a directory [${file.isDirectory()}]
12:19:22.237 [main] DEBUG org.springframework.cloud.contract.verifier.TestGenerator - Found the following contracts []
Properties:
.TestGeneratorApplication {"testFramework":"JUNIT5","testMode":"MOCKMVC","basePackageForTests":null,"baseClassForTests":"com.rodrigow.demo.contract.BaseTestClass","nameSuffixForTests":null,"ruleClassForTests":null,"excludedFiles":[],"includedFiles":[],"ignoredFiles":[],"imports":[],"staticImports":[],"contractsDslDir":"/Users/rodrigow/code/demoSCCPact/build/stubs/META-INF/com.rodrigow.demo.sccwithpact/greeting-service/1.0/contracts","generatedTestSourcesDir":"/Users/rodrigow/code/demoSCCPact/build/generated-test-sources/contractTest/java","generatedTestResourcesDir":"/Users/rodrigow/code/demoSCCPact/build/generated-test-resources/contractTest","stubsOutputDir":null,"stubsSuffix":"stubs","assertJsonSize":false,"includedContracts":".*","includedRootFolderAntPattern":"**/","packageWithBaseClasses":null,"baseClassMappings":{},"excludeBuildFolders":false,"failOnInProgress":true}
Sample Instructions to create the Pact Server locally alongside with the code are hosted in https://github.com/rodrigow/spring-cloud-contract-with-pact-sample
Have you added Pact converter to the classpath? Check this part of the docs https://docs.spring.io/spring-cloud-contract/docs/current/reference/html/howto.html#how-to-pact-producer
I believe you are referring to the spring-cloud-contract-pact, right? It is there. Please let me know if you are not referring to this dependency.
In time: The code snippet of 7.4. Pact for Producers seems to be missing. I've found it in another "location", 7.4. Pact for Producers
Yeah that was the part I was referring to. I need to see a reproducer. Without it it's hard to even wonder what could possibly be wrong.
I'm not sure what a "reproducer" would be. Were you able to download the project and run the ./gradlew contractTest ?
Wow, I need to change my glasses - I haven't noticed that you provided a sample. :facepalm:
No need to apologize, maybe I should have been more clear about the sample...
Closing due to age of the question. If you would like us to look at this issue, please comment and we will look at re-opening the issue.