So… I’ve read the documentation page on how to set up Travis CI integration, followed those instructions, and everything seemed to work perfectly. I haven’t really exercised this thing or looked at it carefully until now. I thought “wow, that was easy” and put it aside. Now that I look at it again… I realize that the collection that I am testing with newman within my Travis build has my production URLs embedded within it. When I look at my Travis build log, lo and behold, tests seem to succeed, because they are running against production! I feel dumb about this, but… why do the docs not talk about this? Obviously, I need the newman tests to run against the Travis build, but I don’t know how to make that happen. Maybe has something to do with environments? I haven’t used them yet, but my impression is that it’s just a way to set environment variables in a run. Presumably the values set in the environment are fixed, so… I still don’t know how to set the domain to run against to be whatever Travis needs to set to get the tests to run against IT. What am I missing here? Thanks.
@djiann Thanks for the suggestion. In order to get tests working with your Travis build environment, you’ll have to update all request URLs in your collection to use variables for hosts, like so: {{url}}/my/api/path
. Next, you can set up a test Postman environment file that has a variable called url
pointing to the localhost server running on the Travis agent. Next, your Travis build sequence can be updated to include the -e
option in the newman run ...
command, which will ensure that your collection runs against the test environment instead of production.