Search code examples
springspring-bootframeworkscloudcontract

Spring Cloud Contract testing without Spring Framework (Boot)


I would like to know if it is possible to use Spring Cloud Contracts with other frameworks not only Spring Boot? An example of another framework I'd like to test Spring Cloud Contract is KumuluzEE.


Solution

  • Are you asking about the consumer side or the producer side?

    On the consumer side you can use the JUnit rule (http://cloud.spring.io/spring-cloud-static/Edgware.RELEASE/multi/multi__spring_cloud_contract_stub_runner.html#_stub_runner_junit_rule) .

    On the producer side you can use the EXPLICIT mode (e.g. http://cloud.spring.io/spring-cloud-static/Edgware.RELEASE/multi/multi__contract_dsl.html#_working_with_context_paths).

    That way the generated tests will assume that you're sending a request to a real running application. So in the base class (or before even running these tests) you'd have to start your app and then point to the URL (like here https://github.com/marcingrzejszczak/the-legacy-app/blob/master/stubs/src/test/java/com/example/contracts/BaseClass.java#L15)