MDL-67687 behat: Make axe tests optional
This commit is contained in:
@@ -49,6 +49,7 @@ list($options, $unrecognized) = cli_get_params(
|
||||
'torun' => 0,
|
||||
'optimize-runs' => '',
|
||||
'add-core-features-to-theme' => false,
|
||||
'axe' => false,
|
||||
),
|
||||
array(
|
||||
'j' => 'parallel',
|
||||
@@ -71,6 +72,7 @@ Options:
|
||||
-m, --maxruns Max parallel processes to be executed at one time.
|
||||
--fromrun Execute run starting from (Used for parallel runs on different vms)
|
||||
--torun Execute run till (Used for parallel runs on different vms)
|
||||
--axe Include axe accessibility tests
|
||||
|
||||
-o, --optimize-runs Split features with specified tags in all parallel runs.
|
||||
-a, --add-core-features-to-theme Add all core features to specified theme's
|
||||
@@ -102,7 +104,10 @@ if ($options['parallel'] && $options['parallel'] > 1) {
|
||||
}
|
||||
} else {
|
||||
// Only sanitize options for single run.
|
||||
$cmdoptionsforsinglerun = array('add-core-features-to-theme');
|
||||
$cmdoptionsforsinglerun = [
|
||||
'add-core-features-to-theme',
|
||||
'axe',
|
||||
];
|
||||
|
||||
foreach ($cmdoptionsforsinglerun as $option) {
|
||||
if (!empty($options[$option])) {
|
||||
|
||||
@@ -54,6 +54,7 @@ list($options, $unrecognized) = cli_get_params(
|
||||
'torun' => 0,
|
||||
'optimize-runs' => '',
|
||||
'add-core-features-to-theme' => false,
|
||||
'axe' => false,
|
||||
),
|
||||
array(
|
||||
'h' => 'help',
|
||||
@@ -69,7 +70,7 @@ $help = "
|
||||
Behat utilities to manage the test environment
|
||||
|
||||
Usage:
|
||||
php util.php [--install|--drop|--enable|--disable|--diag|--updatesteps|--help] [--parallel=value [--maxruns=value]]
|
||||
php util.php [--install|--drop|--enable|--disable|--diag|--updatesteps|--axe|--help] [--parallel=value [--maxruns=value]]
|
||||
|
||||
Options:
|
||||
--install Installs the test environment for acceptance tests
|
||||
@@ -78,6 +79,7 @@ Options:
|
||||
--disable Disables test environment
|
||||
--diag Get behat test environment status code
|
||||
--updatesteps Update feature step file.
|
||||
--axe Include axe accessibility tests
|
||||
|
||||
-j, --parallel Number of parallel behat run operation
|
||||
-m, --maxruns Max parallel processes to be executed at one time.
|
||||
|
||||
@@ -49,6 +49,7 @@ list($options, $unrecognized) = cli_get_params(
|
||||
'updatesteps' => false,
|
||||
'optimize-runs' => '',
|
||||
'add-core-features-to-theme' => false,
|
||||
'axe' => false,
|
||||
),
|
||||
array(
|
||||
'h' => 'help',
|
||||
@@ -75,6 +76,7 @@ Options:
|
||||
--disable Disables test environment
|
||||
--diag Get behat test environment status code
|
||||
--updatesteps Update feature step file.
|
||||
--axe Include axe accessibility tests
|
||||
|
||||
-o, --optimize-runs Split features with specified tags in all parallel runs.
|
||||
-a, --add-core-features-to-theme Add all core features to specified theme's
|
||||
@@ -181,6 +183,9 @@ if ($options['install']) {
|
||||
behat_config_manager::set_behat_run_config_value('behatsiteenabled', 1);
|
||||
}
|
||||
|
||||
// Define whether to run Behat with axe tests.
|
||||
behat_config_manager::set_behat_run_config_value('axe', $options['axe']);
|
||||
|
||||
// Enable test mode.
|
||||
behat_util::start_test_mode($options['add-core-features-to-theme'], $options['optimize-runs'], $parallel, $run);
|
||||
|
||||
|
||||
@@ -491,4 +491,23 @@ class behat_util extends testing_util {
|
||||
$linecount = count(explode("\n", $formattedmessage));
|
||||
fwrite(STDOUT, str_repeat(cli_ansi_format("<cursor:down>"), $linecount - 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a text-based site version description.
|
||||
*
|
||||
* @return string The site info
|
||||
*/
|
||||
public static function get_site_info() {
|
||||
$siteinfo = parent::get_site_info();
|
||||
|
||||
$accessibility = empty(behat_config_manager::get_behat_run_config_value('axe')) ? 'No' : 'Yes';
|
||||
|
||||
$siteinfo .= <<<EOF
|
||||
Run optional tests:
|
||||
- Accessibility: {$accessibility}
|
||||
|
||||
EOF;
|
||||
|
||||
return $siteinfo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,6 +72,10 @@ class behat_accessibility extends behat_base {
|
||||
* @param array $extratags The list of tags, in addition to the standard tags, to run
|
||||
*/
|
||||
protected function run_axe_for_tags(array $standardtags = [], array $extratags = []): void {
|
||||
if (!behat_config_manager::get_behat_run_config_value('axe')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$this->has_tag('accessibility')) {
|
||||
throw new DriverException(
|
||||
'Accessibility tests using Axe must have the @accessibility tag on either the scenario or feature.'
|
||||
|
||||
Reference in New Issue
Block a user