Search code examples
spring-cloud-contract

Spring Cloud Contract with TestNG


As far as I understand(beginner level on Spring Cloud Contract), the contract tests generated from the groovy contracts are with junit. What if I want to use TestNG? Basically I want to group my tests with TestNG annotation @Test(groups="unit") and @Test(groups="contract") in order to separate unit tests and contract tests using ssomething like mvn test -Dgroups=unit and mvn test -Dgroups=contract.

Thank you for your help.


Solution

  • Currently, we don't support this out of the box. You would have to write your own org.springframework.cloud.contract.verifier.builder.SingleTestGenerator implementation (by extending, for example, the JavaTestGenerator and referencing it in spring.factories file) but that can be quite time-consuming, unfortunately.