Verifying calls in integration tests #296

Closed
opened 2025-12-29 15:20:01 +01:00 by adam · 5 comments
Owner

Originally created by @ilia-cy on GitHub (Sep 20, 2020).

We are using the Wiremock server in our CI integration tests mechanism by pre-defining routes and their expected responses, mainly for third party API mocks.

I was wondering if there is a way of verifying that specific requests were performed, but from the docs I could only find the stubs Verify approach (https://github.com/WireMock-Net/WireMock.Net/wiki/Stubbing#verify-interactions).
In our case the server runs as a standalone process and is only in charge of the pre defined responses.

My naive idea of how to do it is by saving a state on the server by running a callback when requested routes were called (again, pre-defined), and opening a designated route which is called by the tests which in turn checks the state and returns a response of whether the requsted route was called.

Another option, I guess, could be opening a designated route which will query the server logs with a specific path to check whether it was called.

Have I missed an out of the box solution for my problem, or is one is the above a possible solution?

Thanks!

Originally created by @ilia-cy on GitHub (Sep 20, 2020). We are using the Wiremock server in our CI integration tests mechanism by pre-defining routes and their expected responses, mainly for third party API mocks. I was wondering if there is a way of verifying that specific requests were performed, but from the docs I could only find the stubs `Verify` approach (https://github.com/WireMock-Net/WireMock.Net/wiki/Stubbing#verify-interactions). In our case the server runs as a standalone process and is only in charge of the pre defined responses. My naive idea of how to do it is by saving a state on the server by running a callback when requested routes were called (again, pre-defined), and opening a designated route which is called by the tests which in turn checks the state and returns a response of whether the requsted route was called. Another option, I guess, could be opening a designated route which will query the server logs with a specific path to check whether it was called. Have I missed an out of the box solution for my problem, or is one is the above a possible solution? Thanks!
adam added the question label 2025-12-29 15:20:01 +01:00
adam closed this issue 2025-12-29 15:20:02 +01:00
Author
Owner

@StefH commented on GitHub (Sep 20, 2020):

Hello @ilia-cy, do you use WireMock.Net as a standalone exe file, web-app or docker instance?

Or do you just start a new WireMockService in your unit tests?

@StefH commented on GitHub (Sep 20, 2020): Hello @ilia-cy, do you use WireMock.Net as a standalone exe file, web-app or docker instance? Or do you just start a new WireMockService in your unit tests?
Author
Owner

@ilia-cy commented on GitHub (Sep 20, 2020):

Hello @ilia-cy, do you use WireMock.Net as a standalone exe file, web-app or docker instance?

Or do you just start a new WireMockService in your unit tests?

As a web app.
It's basically another service that is running among the other services that are communicating with each other, and is there to mock the external API calls.

@ilia-cy commented on GitHub (Sep 20, 2020): > Hello @ilia-cy, do you use WireMock.Net as a standalone exe file, web-app or docker instance? > > Or do you just start a new WireMockService in your unit tests? As a web app. It's basically another service that is running among the other services that are communicating with each other, and is there to mock the external API calls.
Author
Owner

@StefH commented on GitHub (Sep 21, 2020):

Hello @ilia-cy.

I think the option you have is to use the admin interface https://github.com/WireMock-Net/WireMock.Net/wiki/Admin-API-Reference#__adminrequests and use the POST /__admin/requests/find method.

Please tell me if this works for you (because this requests/find functionality it's not very extended).

@StefH commented on GitHub (Sep 21, 2020): Hello @ilia-cy. I think the option you have is to use the admin interface https://github.com/WireMock-Net/WireMock.Net/wiki/Admin-API-Reference#__adminrequests and use the `POST /__admin/requests/find` method. Please tell me if this works for you (because this requests/find functionality it's not very extended).
Author
Owner

@ilia-cy commented on GitHub (Sep 21, 2020):

Thanks for the response @StefH
I was able to enable the admin interface and i'm able to get all requests via GET /__admin/requests.

For whoever is interested, to use the POST /__admin/requests/find API as you suggested, you'll need to search for properties in the RequestModel class.

For example, this will return all requests that were performed to this specific path.

curl --location --request POST 'http://localhost:5028/__admin/requests/find' \
--header 'Content-Type: application/json' \
--data-raw '{
    "path": "/path/to/search/for"
}

Thanks for the help!

@ilia-cy commented on GitHub (Sep 21, 2020): Thanks for the response @StefH I was able to enable the admin interface and i'm able to get all requests via `GET /__admin/requests`. For whoever is interested, to use the `POST /__admin/requests/find` API as you suggested, you'll need to search for properties in the [RequestModel class](https://github.com/WireMock-Net/WireMock.Net/blob/master/src/WireMock.Net.Abstractions/Admin/Mappings/RequestModel.cs). For example, this will return all requests that were performed to this specific path. ``` cmd curl --location --request POST 'http://localhost:5028/__admin/requests/find' \ --header 'Content-Type: application/json' \ --data-raw '{ "path": "/path/to/search/for" } ``` Thanks for the help!
Author
Owner

@StefH commented on GitHub (Sep 22, 2020):

@ilia-cy I've added your curl example to the WIKI.

Closing this issue, if you have other questions, just create a new issue.

@StefH commented on GitHub (Sep 22, 2020): @ilia-cy I've added your curl example to the WIKI. Closing this issue, if you have other questions, just create a new issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#296