Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Behat "base_url" from command line

Tags:

behat

mink

I would like to know if it's possible to set the base_url via the command line. Example

bin/behat --base_url=http://google.fr

I would like to avoid creating a new profile and passing it via the command line each time I have to test a new url, for flexibility purpose.

Is there any trick here to do this ?

Thank you.

like image 905
lnki Avatar asked Nov 06 '13 14:11

lnki


2 Answers

I found the solution by myself.

Just pass the base_url in the BEHAT_PARAM environment variable.

export BEHAT_PARAMS="context[parameters][base_url]=http://google.fr"

Then run behat

bin/behat
like image 181
lnki Avatar answered Jan 01 '23 11:01

lnki


Alternatively if you are using Mink you could define a profile in behat.yml

# behat.yml
default:
    extensions:
        Behat\MinkExtension\Extension:
            base_url: http://local.mysite.com
            goutte: ~
            selenium2: ~

dev:
    extensions:
        Behat\MinkExtension\Extension:
            base_url: http://dev.mysite.com

And then you can run your tests against local.mysite.com by default with

$ behat

Or against dev.mysite.com with

$ behat --profile=dev
like image 39
Marcus Clements Avatar answered Jan 01 '23 10:01

Marcus Clements