Slackbot
12/08/2023, 7:19 AMMarcel
12/08/2023, 7:27 AM@RegisterExtension
but it appears the WM server isn’t started yet when my @BeforeEach
is invoked.
@QuarkusTest
internal class FooTest {
@RegisterExtension
val wireMockExtension = WireMockExtension.newInstance()
.options(wireMockConfig().dynamicPort().dynamicHttpsPort())
.build()!!
@BeforeEach
fun `set-up mocks`() {
// fails with NPE because server isn't started yet
wireMockExtension.baseUrl()
}
}
Marcel
12/08/2023, 8:45 AM@QuarkusTest
internal class FooTest {
companion object {
private val wireMockServer = WireMockServer(options().dynamicPort())
@JvmStatic
@BeforeAll
fun startWireMockServer() {
wireMockServer.start()
}
@JvmStatic
@AfterAll
fun stopWireMockServer() {
wireMockServer.stop()
}
}
}
The downside is that I need to prefix all WM method calls like stubFor
or verify
with wireMockServer.
for them to go to the one WM instance created manually.Oleg Nenashev
12/08/2023, 10:07 AMOleg Nenashev
12/08/2023, 10:08 AM