Context
I am developing a web application that avails of a suite of REST tests built for Postman.
The idea is that you can run the tests manually with Postman as a REST client against the application runtime, and the Maven pom configures newman to run them automatically in the CI pipelines as integration tests when ever a build is triggered.
This has run fairly well in the past.
Requirement
However, due to an overhaul in business logic, many of those tests now require a binary body as a file resource in POST requests (mostly zip archives).
I need those tests to work in 3 scenarios:
- Manually when running individual tests with Postman locally, against a runtime of the web application
- Semi-manually as above, but by triggering a runner in Postman
- Automatically, when newman is started by maven during the integration tests phase of our pipeline
In order to make sure the path to the file in each request would work regardless of the way the tests are run, I have added a Postman environment variable in each profile. The variable would then be used by the collection in the relevant requests, e.g.:
"body": {
"mode": "file",
"file": {
"src": "{{postman_resources_path}}/empty.zip"
}
},
The idea would be that:
- locally, you manually overwrite the value of
postman_resources_path
in the profile, in order to point to an absolute path in your machine (e.g. simply where you have the resources in source control) - this would then resolve it both for manual tests and a local runner - for the CI pipelines, the same would apply with a default value pointing to a path relative to the
--working-dir
value, which would be set in the newman command-line parametrization in the exec-maven-plugin already in use to run newman
Problem
While I haven't had a chance to test the pipeline yet with those assumptions, I can already notice that this isn't working locally.
Looking at a request, I can see the environment variable is not being resolved:
Conversely, here is the value that I manually set in the profile I'm running the request against:
TL;DR The request fails, since the resource is not found.
The most relevant literature I've found does not address my use case entirely, but the solution given seems to follow a similar direction: "variabilize" the path - see here.
I could not find anything specific enough in the Postman reference.