quarkiverse / quarkus-wiremock

Quarkus extension for launching an in-process Wiremock server
https://wiremock.org/
Apache License 2.0
15 stars 8 forks source link

Wiremock for @QuarkusTest and @QuarkusIntagrationTest simultaneously #81

Closed DudekJakub closed 1 month ago

DudekJakub commented 6 months ago

Hello.

I would like to ask how can I handle Wiremock usage simultaneously for both: @QuarkusTest and @QuarkusIntegrationTest.

Here is simple reproducer: GITHUB

I think that my case is quite simple and straightforward. I'd like to understand how should I properly set properties for native test in my application.properties files (main & test).

Please use wiremock branch in provided reproducer -> then go to test/kotlin/org/acme/GreetingResourceTest and check testHelloEndpoint(). As you can see here, I am registering my client's endpoint for wiremock which url matches the url in ExampleClient.class. So far everything is easy to understand.

This test with @QuarkusTest annotation works properly. There is property quarkus.rest-client."org.acme.client.ExampleClient".url=http://localhost:${%dev,test.quarkus.wiremock.devservices.port} set in test/resources/application.properties so wiremock is able to determine correct url for the test.

My issue occurs when I run @QuarkusIntegrationTest (check native-test dir). Since native env doesn't look for test properties, to make this test passes I had to set exactly the same property as above one in main/resources/application.properties file but unfortunately this approach is obviously bad one (guess I don't have to write why).

So my question is, how can I overcome this problem properly so both tests (native + normal) will use correct url so in result wiremock will be able to determine client's path as expected.

I realise that most probably it isn't any bug but rather my lack of understanding of how native tests work.

Thank you for any advice/feedback for my issue in advance. :)

edeandrea commented 6 months ago

Hi @DudekJakub I'm doing this currently in the Quarkus superheroes sample application using a test profile. Take a look at https://github.com/quarkusio/quarkus-super-heroes/blob/main/rest-narration/src/test/java/io/quarkus/sample/superheroes/narration/rest/NarrationResourceIT.java#L185

github-actions[bot] commented 4 months ago

@chberger This is being labeled as stale.

oleg-nenashev commented 3 months ago

Not stale

github-actions[bot] commented 1 month ago

@chberger This is being labeled as stale.

github-actions[bot] commented 1 month ago

@chberger This is being closed due to inactivity.