Cant handle "Behat only can run if test mode is enabled."

Cant handle "Behat only can run if test mode is enabled."

by Olexandr Berezhnyk -
Number of replies: 6

After I run $ php admin/tool/behat/cli/util.php --enable I see this message:

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

vendor/bin/behat --config /var/www/education/moodle/admin/tool/behat/cli/tests/behat/behat/behat.yml

Then I run my behat feature file:

vendor/bin/behat --config /var/www/education/moodle/admin/tool/behat/cli/tests/behat/behat/behat.yml local/intelliboard/tests/behat/student_dashboard.feature

Its message to me:

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

I read that doc a lot, there is no any info to solve my issue, because I did util.php --enable and even check a behat.yml and found my student_dashboard.feature test and context variable and related for it .php filename with test steps.

I even install NodeJS Gherkin validator and check my feature for errors - its clean.

Average of ratings: -
In reply to Olexandr Berezhnyk

Re: Cant handle "Behat only can run if test mode is enabled."

by Rajesh Taneja -

Hello Olexandr,


Can you try:

  1. php admin/tool/behat/cli/init.php
  2. vendor/bin/behat --config /var/www/education/moodle/admin/tool/behat/cli/tests/behat/behat/behat.yml local/intelliboard/tests/behat/student_dashboard.feature


In reply to Rajesh Taneja

Re: Cant handle "Behat only can run if test mode is enabled."

by Olexandr Berezhnyk -

Yes I tried and it's like a Moodle Joke because it message what tests enabled, but when I run next command it message to me this:

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

Attachment Screenshot from 2017-03-01 094033.png
In reply to Olexandr Berezhnyk

Re: Cant handle "Behat only can run if test mode is enabled."

by Rajesh Taneja -

Aha.... Can you please share the config.php ?

I can see behat.yml is being stored under the moodle code base and that is kinda strange. 

For some reason while writing $CFG->behat_dataroot/test_environment_enabled.txt php is failing but not throwing any failure. But while checking file it can't find one and fails.

Main reason seems $CFG->behat_dataroot is incorrectly set.

In reply to Rajesh Taneja

Re: Cant handle "Behat only can run if test mode is enabled."

by Olexandr Berezhnyk -

Yes sure:

$CFG->dbtype    = 'mysqli';      // 'pgsql', 'mariadb', 'mysqli', 'mssql', 'sqlsrv' or 'oci'
$CFG->dblibrary = 'native';     // 'native' only at the moment
$CFG->dbhost    = 'localhost';  // eg 'localhost' or 'db.isp.com' or IP
$CFG->dbname    = 'moodle';     // database name, eg moodle
$CFG->dbuser    = 'root';   // your database username
$CFG->dbpass    = '11111';   // your database password
$CFG->prefix    = 'mdl_';       // prefix to use for all table names
$CFG->dboptions = array(
    'dbpersist' => false,       // should persistent database connections be
                                //  used? set to 'false' for the most stable
                                //  setting, 'true' can improve performance
                                //  sometimes
    'dbsocket'  => false,       // should connection via UNIX socket be used?
                                //  if you set it to 'true' or custom path
                                //  here set dbhost to 'localhost',
                                //  (please note mysql is always using socket
                                //  if dbhost is 'localhost' - if you need
                                //  local port connection use '127.0.0.1')
    'dbport'    => '',          // the TCP port number to use when connecting
                                //  to the server. keep empty string for the
                                //  default port
);
$CFG->behat_prefix = 'b_';
$CFG->behat_dataroot = '/var/www/education/moodle/tests/behat';
$CFG->behat_wwwroot = 'http://127.0.0.1';
In reply to Olexandr Berezhnyk

Re: Cant handle "Behat only can run if test mode is enabled."

by Rajesh Taneja -

Try change (Create a directory /var/moodledata/test and make sure you have proper permissions.)

$CFG->behat_dataroot = '/var/moodledata/test';

I was able to reproduce the issue if I set 

$CFG->behat_dataroot = '/var/www/education/moodle/admin/tool/behat/cli/tests/behat';


Seems your php setup is not throwing any warnings... You should setup dataroot to be outside moodle code base and not within that path. In your case it's causing some recursion and failing.

In reply to Olexandr Berezhnyk

Re: Cant handle "Behat only can run if test mode is enabled."

by Carl Greenwood -

Hi,


I'm experiencing this same issue and was wondering if you managed to resolve it and if so how?