5

From the docs:

To read the body content from a file, place the file under the __files directory. By default this is expected to be under src/test/resources when running from the JUnit rule. When running standalone it will be under the current directory in which the server was started. To make your stub use the file, simply call bodyFile() on the response builder with the file’s path relative to __files:

Is it possible to change it? Why would WireMock insist on this specific directory?

IsaacLevon
  • 2,260
  • 4
  • 41
  • 83

1 Answers1

7

WireMock insists on that specific directory because it has to have some specific directory.

If you want to change it, you can do so. Check out the File Locations section under the configuration documentation.

agoff
  • 5,818
  • 1
  • 7
  • 20
  • 3
    It's possible to change the root folder, but the `__files` child folder is not changeable. It's declared [here](https://github.com/wiremock/wiremock/blob/master/src/main/java/com/github/tomakehurst/wiremock/core/WireMockApp.java#L169) and transferred to the StubResponseRenderer. The filesource is then used everywhere. – luckyluke Jan 07 '22 at 21:17
  • Thanks @luckyluke for investigating this for all of us. Please consider make it an answer and I will upvote. For example, in this same question, and also [here](https://stackoverflow.com/questions/48203837/stubbing-with-wiremock-withbodyfile-location-other-than-files) – WesternGun Apr 12 '23 at 12:39