I want to classified tests to run them for different purposes. As far as, I search I could not an option to tag
some test and run test on demand. I also looked at Chaijs if it has such a feature, but could not be able to find a solution.
What I want to do is add some tag like the following:
@health_check
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
@smoke
pm.test("Product should be correct", function () {
var jsonData = pm.response.json();
var product = pm.variables.get("PRODUCT");
pm.expect(jsonData.meta.appId).to.eql(product);
});
and run it like as following or anyway achieve this:
$ newman run mycollection.json -tag smoke
That tag
type option is not something that's ever been available in the app or in Newman.
You could use the --folder
option on the CLI and organise your collections to include requests within those specific folders, that cover those scenarios.
For example:
$ newman run mycollection.json --folder healthCheck --folder smoke
Alternatively, you could use a global variable to act as a switch in the control if specific tests/groups of tests are run.
Wrapping the test in an if
statement like this:
if(pm.globals.get('smoke_check') === "runCheck") {
pm.test("Status code is 200", () => pm.response.to.have.status(200));
}
Then passing in a global variable in the cli using the --global-var
flag.
$ newman run mycollection.json --global-var "smoke_check=runCheck"