Skip to content

Conversation

@brneto
Copy link

@brneto brneto commented Aug 18, 2021

closes #27747

@pivotal-cla
Copy link

@brneto Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 18, 2021
@pivotal-cla
Copy link

@brneto Thank you for signing the Contributor License Agreement!

@brneto
Copy link
Author

brneto commented Aug 18, 2021

@wilkinsona It failed with message A build scan was not published as you have not authenticated with server 'ge.spring.io'., is there something more I have to do?

Copy link
Member

@wilkinsona wilkinsona left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks very much for the PR, @brneto. I've left a couple of comments for your consideration when you have a moment.

@wilkinsona
Copy link
Member

It failed with message A build scan was not published as you have not authenticated with server 'ge.spring.io'., is there something more I have to do?

That's not a failure. It's just indicating that it couldn't publish a build scan to ge.spring.io. The build itself should be unaffected.

@brneto
Copy link
Author

brneto commented Aug 18, 2021

I'm still intrigued why this doesn't work:

@WebFluxTest
@AutoConfigureRestDocs
abstract class ContractTest {

    @TestConfiguration(proxyBeanMethods = false)
    static class RestDocsParameterizedOutput {

        @Bean
        WebTestClientBuilderCustomizer restDocsParameterizedOutput() {
            return builder -> builder.entityExchangeResultConsumer(document("{class-name}/{method-name}"));
        }
    }

    @Autowired
    private WebTestClient webTestClient;

    void webTestClientSetup() {
        RestAssuredWebTestClient.webTestClient(webTestClient);
    }
}

While this does:

@WebFluxTest
@AutoConfigureRestDocs
abstract class ContractTest {

    @Autowired
    private ApplicationContext context;

    @Autowired
    private WebTestClientRestDocumentationConfigurer configurer;

    void webTestClientSetup() {
        RestAssuredWebTestClient.webTestClient(
                WebTestClient
                        .bindToApplicationContext(context)
                        .configureClient()
                        .filter(configurer)
                        .entityExchangeResultConsumer(document("{class-name}/{method-name}"))
                        .build());
    }
}

Any thought why this is happening?

Thanks!

@brneto
Copy link
Author

brneto commented Aug 18, 2021

@wilkinsona I've just figured out why this is happening! That's because the tests generated by the Spring Contract Test does not have the @TestConfiguration creating the WebTestClientBuilderCustomizer bean. Would you have any suggestion how I could overcome this? Thanks!

@brneto
Copy link
Author

brneto commented Aug 18, 2021

@wilkinsona It worked externalising the @TestConfiguration class and importing it.
e.g.

@WebFluxTest
@AutoConfigureRestDocs
@Import(ContractTestConfiguration.class)
abstract class ContractTest {

    @BeforeEach
    void webTestClientSetup(@Autowired WebTestClient webTestClient) {
        RestAssuredWebTestClient.webTestClient(webTestClient);
    }
}

@brneto
Copy link
Author

brneto commented Aug 19, 2021

@wilkinsona is there anything else I have to do or this is it for this PR?

Do you know why this concourse-ci/status check is still in failure state?

@wilkinsona
Copy link
Member

It's failing because the code in MyWebTestClientBuilderCustomizerConfiguration doesn't compile. It appears to be missing a static import for WebTestClientRestDocumentation.document. The package declaration is also incorrect. Don't worry about it, though. We can take care of it when we come to merge this.

@wilkinsona wilkinsona added type: documentation A documentation update and removed status: waiting-for-triage An issue we've not yet triaged labels Aug 19, 2021
@wilkinsona wilkinsona added this to the 2.4.x milestone Aug 19, 2021
@wilkinsona wilkinsona added the for: merge-with-amendments Needs some changes when we merge label Aug 19, 2021
@brneto
Copy link
Author

brneto commented Aug 19, 2021

Let me fix that. Give me a sec.

@brneto
Copy link
Author

brneto commented Aug 19, 2021

@wilkinsona, just did ae79b33. Sorry for that! :(

@brneto
Copy link
Author

brneto commented Aug 19, 2021

@wilkinsona it's still failing! Have I made any other mistake? :(

@scottfrederick
Copy link
Contributor

@brneto Just a small checkstyle violation. You can push another commit to fix that, or as Andy said we're happy to fix it when merging.

@wilkinsona wilkinsona changed the title Document how to parameterize output directory for WebTestClient/Rest Assured Document how to parameterize output directory for REST Docs with WebTestClient Aug 20, 2021
@brneto brneto requested a review from wilkinsona August 20, 2021 08:26
@wilkinsona wilkinsona removed the for: merge-with-amendments Needs some changes when we merge label Aug 20, 2021
@brneto

This comment has been minimized.

@wilkinsona

This comment has been minimized.

@wilkinsona
Copy link
Member

@brneto Thanks very much for making your first contribution to Spring Boot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: documentation A documentation update

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document how to use WebTestClientBuilderCustomizer to configure REST Docs' parameterized output

5 participants