3

I want to pass multiple environment variables using the newman CLI.

newman run myCollection.json --env-var baseurl="fancy/url" --env-var user="admin" --env-var password="admin123" `

I hate that I have to write -env-var for each of the variables I want to set..

Is there a nicer way to do it?

I want to avoid passing the environment variables to newman as json.

Irvin Kubat
  • 31
  • 1
  • 2

1 Answers1

2

If(as you said) the usage of environment/Global JSON files is not an option, i would suggest to a data file. You cann add the credentials in an csv file as username,password pairs. E.g.

user,password
"admin","admin123"

You only have to add -d "datafile.csv" to your newman command

You can access them by using data.user and data.password in your test-code. If you need them in the request-body, URL, or header: Just use {{user}} an {{password}} aus usual.

An other benefit: With datafiles you can execute each collection for multiple times(aka. iterations), for each row.

DieGraueEminenz
  • 830
  • 2
  • 8
  • 18