2

currently, I am running my postman scripts using Newman by the following command Newman run [filename] .json -e [env name]

I have the env.json file set up, but for one of my variables there could be more than 1 input and I would like to control what to call from the command line... for example in my env file now we have


            {
            "key": "type",
            "value": "collection",
            "description": "",
            "enabled": true
            },

the type could either be "collection" or "series" and I would like to be able to run the test and giving the input from the command line .. instead of creating another .json env file.

Thanks,

Shabeer K
  • 1,489
  • 16
  • 23
Milad
  • 27
  • 5

2 Answers2

0

Have you tried to set-up this specific variable with newman?

You have two different command-line-options there:

--global-var <key=value> --env-var <key=value>

Just type newman run --help for further details.

In this case, i would suggest removing this special env-variable from your .json file and specify it over the command line option of newman.

In your case:

newman run [filename] .json -e [env name] --env-var value="Collection"

or

newman run [filename] .json -e [env name] --env-var value="series"

Hope this was helpful.

Cheers

DieGraueEminenz
  • 830
  • 2
  • 8
  • 18
-1

Below you can see the example in newman npm modules in newman/test/unit/options.test.js file and find environment and global key words

Example from newsman

options({
   globals: './test/fixtures/run/spaces/simple-variables.json'
    }, function (err, result) {

});

JSON file

    {
      "name": "globals",
      "values": [{
        "key": "var-1",
        "type": "any",
        "value": "value-1"
      }, {
        "key": "var-2",
        "type": "any",
        "value": "value-2"
      }]
    }
i_love_cs
  • 41
  • 6