perltestingtest-moreperl-prove

How can I pass prove (Test::More) an argument, e.g. an API URL?


Parts of my test suite relies on an API URL. Sometimes I want to run my test using another URL. Is there a way to pass this argument to prove, or would I need to edit the file that defined the API URL?


Solution

  • Maybe set a default URL in the test program but allow it to be overridden by an environment variable.

    my $url = $ENV{MY_TEST_URL} // 'http://api.example.com/';