Hey :wave: I have a case that yes I can try the st...
# help
a
Hey 👋 I have a case that yes I can try the stateful behavior but it gput some dependencies on the order of the tests. I am using the standalone server with iOS UI tests: • In one test I want to stub the request GET order/active for 404 and some response • Then in another test I want to stub the same request GET order/active but for 200 and some response how can I achieve that, is there a way to tell the tests which mapping file it should use?
and by the way if we have kind of some way that could interact with wiremock in code like in Java it would be AMAZING!!!
b
Hey @Aya Akl am I right in assuming that you have defined your stub mappings in JSON files? Because in Java code this would be straightforward, just add the mapping as part of your test. You can interact with / add / remove mappings through the WireMock admin API, which runs at
<http://yourmockserver>:yourport/__admin/mappings
, you can POST new JSON mapping definitions (the same as you have on your file system) to that. Full specification here: https://wiremock.org/docs/standalone/admin-api-reference/
a
Hey @Bas Dijkstra Thank you for your answer, yes I have all my mappings in the mappings folder, the problem I am not using Java, I am using XCUITest & Swift. And whenever I provide the endpoint
order/active
it gets the latest mapping and this is not what I want to do. And also I don’t want the stateful behavior because first it puts some dependency on when to run the tests and also I need these different mappings for same endpoint in different test files I tried to interact with the API by doing some resetting but I am not sure if I want to add the mappings, this means it will happen on the fly? and then I can achieve that this same endpoint will be mocked independently ?
b
I think it works that way, yes. I’ve not actually tested / used it myself, though. @Oleg Nenashev can you shed some light on this question?
👀 1
a
if yes, I could create a client of my own as a helper in swift in our project and interact that way then 🤞
o
@Aya Akl if you want to isolate execution on the test level, I think you should rather consider having an endpoint prefix for each test It is probably a moonshot, but you may be able use WireMock SDK for C/C++ through the Testcontainers library. Swift can include native C/C++ shared libraries but it is not something I have tested
👀 1
a
I will check that