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

Friendly magic - eliminate the need to @BeforeEach a context.setTarget(new HttpTestTarget("localhost", 8081)) #10

Open
holly-cummins opened this issue Oct 19, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@holly-cummins
Copy link
Contributor

We can elimiminate some boilerplate, as we do for other extensions like rest-assured.

At the moment, every provider tests need boilerplate like the following:

    @ConfigProperty(name = "quarkus.http.test-port")
    int quarkusPort;


    @BeforeEach
    void beforeEach(PactVerificationContext context) {
        context.setTarget(new HttpTestTarget("localhost", this.quarkusPort));
        [...]

In a @QuarkusTest, there's only one set of values for the host and port, so we should do that context initialisation automatically.

@holly-cummins holly-cummins added the enhancement New feature or request label Oct 19, 2022
@holly-cummins
Copy link
Contributor Author

The QuarkusTestExtension.getEndpointPath() method may help with this. It's also worth looking at how it's done for RestAssured - instead of instrumentation, the test extension calls a static helper provided by rest assured itself:

                    runningQuarkusApplication.getClassLoader().loadClass(RestAssuredURLManager.class.getName())
                            .getDeclaredMethod("setURL", boolean.class, String.class).invoke(null, secure, endpointPath);

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

No branches or pull requests

1 participant