Moodle Behat Testing Error: "Behat only can run if test mode is enabled"

Moodle Behat Testing Error: "Behat only can run if test mode is enabled"

Kishore K -
回帖数:3

Hi,

I have been trying to setup User Acceptance tests  with the setup instructions given here: https://docs.moodle.org/dev/Running_acceptance_test#Short_version but it keeps throwing the error.


Commands:

>php admin/tool/behat/cli/init.php

Generating autoload files

2.5 behat profile detected, automatically converted to current 3.x format

Acceptance tests environment enabled on http://127.0.0.1/moodle, to run the tests use: 

vendor/bin/behat --config /var/bht_moodledata/behatrun/behat/behat.yml


>vendor/bin/behat --config /var/bht_moodledata/behatrun/behat/behat.yml

Behat only can run if test mode is enabled. More info in http://docs.moodle.org/dev/Acceptance_testing#Running_tests



When I run php admin/tool/behat/cli/init.php it clearly says test environment is enabled and it even creates the behat.yml file. But still it's failing.

Here are some behat details from my config.php

$CFG->wwwroot   = 'http://localhost/moodle';

$CFG->dataroot  = '/var/moodledata';

$CFG->admin     = 'admin';

$CFG->behat_wwwroot = 'http://127.0.0.1/moodle';

$CFG->behat_prefix = 'bht_';

$CFG->behat_dataroot_parent = '/var/bht_moodledata/';

$CFG->behat_dataroot = '/var/bht_moodledata/';


Can someone help me to resolve this issue?


Thank you!


回复Kishore K

Re: Moodle Behat Testing Error: "Behat only can run if test mode is enabled"

Kishore K -

After modifying few things around, I get different error now.


>vendor/bin/behat --config /var/bht_moodledata/behatrun/behat/behat.yml

Behat requirement not satisfied: http://127.0.0.1/moodle is not available, ensure you specified correct url and that the server is set up and started.


When I test manually the URL http://127.0.0.1 is working perfectly fine both in browsers and using wget.


But still Behat is not running, can someone throw some light how to fix this issue?


Thank you!


回复Kishore K

Re: Moodle Behat Testing Error: "Behat only can run if test mode is enabled"

Renaat Debleu -
Core developers的头像 Particularly helpful Moodlers的头像 Plugin developers的头像

127.0.0.1 and localhost are basically the same, depending on your hosts file configuration.

I prefer to work with 2 different ports:

$CFG->wwwroot   = 'http://127.0.0.1';
$CFG->behat_wwwroot = 'http://127.0.0.1:8000';

and adding a php listener (php --server 127.0.0.1:8000 &) in the root directory of your Moodle installation.


回复Renaat Debleu

Re: Moodle Behat Testing Error: "Behat only can run if test mode is enabled"

Kishore K -

Hi Renaat,


Thank you for the reply. 

I tried all those but it still didn't work. I mean with php --server 127.0.0.1:8000 . I still get the same error.