Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sample combining Spring Cloud Contract, WebTestClient, RestAssured and Spring Restdocs #106

Open
stahloss opened this issue Jul 4, 2019 · 1 comment

Comments

@stahloss
Copy link

stahloss commented Jul 4, 2019

Would it be an idea to add a sample combining Spring Cloud Contract, WebTestClient, RestAssured and Spring Restdocs?

WebTestClient can be configured to use Restdocs and so does RestAssured. But under Spring Cloud Contract there seems to be no way to configure so that the snippets are written.
For instance, the following setup doesn't work:

@RunWith(SpringRunner.class)
@WebFluxTest(controllers = StateHandler.class)
public class AbstractSpringCloudContractTestBase {

    @Rule
    public final JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation("target/generated-snippets");

    @Inject
    private ApplicationContext context;
    @MockBean
    private StateRepository stateRepository;
    protected RequestSpecification documentationSpec;

    @Before
    public void beforeEach() {
        WebTestClient webTestClient = WebTestClient.bindToApplicationContext(context).configureClient()
                                           .filter(documentationConfiguration(restDocumentation)).build();
        RestAssuredWebTestClient.webTestClient(webTestClient);
    }
}

Using the spring-cloud-contract-maven-plugin and running the tests will not result in Spring Restdocs output.

An example on how to make this work would be much appreciated.

Question is if there is actually a DSL first approach possible with WebFlux, Spring Cloud Contract and Spring Restdocs...

@marcingrzejszczak
Copy link
Contributor

There might be a problem with that due to spring-projects/spring-framework#26662

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants