mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 21:10:32 +01:00
Verifying calls in integration tests #296
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
Verifyapproach (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!
@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?
@ilia-cy commented on GitHub (Sep 20, 2020):
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.
@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/findmethod.Please tell me if this works for you (because this requests/find functionality it's not very extended).
@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/findAPI 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.
Thanks for the help!
@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.