Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions features/behat-steps.feature
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ Feature: Test that WP-CLI Behat steps work as expected
Given an empty directory
Then the {RUN_DIR} directory should exist

Scenario: Name the run directory after the scenario it belongs to
Given an empty directory

When I run `echo {RUN_DIR}`
Then STDOUT should match /wp-cli-test-run-behat-steps\.feature\.\d+-/

Scenario: Test "Given a specific directory" steps
Given an empty directory
And an empty test-dir directory
Expand Down
15 changes: 11 additions & 4 deletions src/Context/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -1440,11 +1440,16 @@ private static function get_event_file( $scope, &$line ): ?string {

$line = $scenario_feature->getLine();

if ( ! method_exists( $scenario_feature, 'getFile' ) ) {
return null;
if ( method_exists( $scenario_feature, 'getFile' ) ) {
return $scenario_feature->getFile();
}

// Scenario nodes do not know their file, but the feature they belong to does.
if ( method_exists( $scope, 'getFeature' ) ) {
return $scope->getFeature()->getFile();
}

return $scenario_feature->getFile();
return null;
}

/**
Expand Down Expand Up @@ -2393,7 +2398,9 @@ private static function log_run_times_after_suite( AfterSuiteScope $scope ): voi
if ( 'error_log' === self::$output_to ) {
error_log( $log );
} else {
echo PHP_EOL . $log;
// Behat buffers what hooks echo and only prints it for failed scenarios,
// so write to the stream directly to get the report in every run.
fwrite( STDOUT, PHP_EOL . $log . PHP_EOL );
}
}

Expand Down
Loading