Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding clickable editorUrl from codeception.yml #6261

Merged
merged 13 commits into from Dec 21, 2021
17 changes: 16 additions & 1 deletion src/Codeception/Subscriber/Console.php
Expand Up @@ -356,8 +356,23 @@ public function printFail(FailEvent $e)
$this->output->write($e->getCount() . ") ");
$this->writeCurrentTest($failedTest, false);
$this->output->writeln('');

// Clickable `editorUrl`:
if (isset($this->options['editorUrl']) and is_string($this->options['editorUrl'])) {
ThomasLandauer marked this conversation as resolved.
Show resolved Hide resolved
$filePath = codecept_absolute_path(Descriptor::getTestFileName($failedTest));
$message = str_replace('%%file%%', $filePath, $this->options['editorUrl']);
ThomasLandauer marked this conversation as resolved.
Show resolved Hide resolved
$line = 1;
foreach ($fail->getTrace() as $trace) {
if (isset($trace['file']) and $filePath === $trace['file'] and isset($trace['line'])) {
ThomasLandauer marked this conversation as resolved.
Show resolved Hide resolved
ThomasLandauer marked this conversation as resolved.
Show resolved Hide resolved
$line = $trace['line'];
}
}
$message = str_replace(['%%file%%', '%%line%%'], [$filePath, $line], $this->options['editorUrl']);
} else {
$message = codecept_relative_path(Descriptor::getTestFullName($failedTest));
}
$this->message("<error> Test </error> ")
->append(codecept_relative_path(Descriptor::getTestFullName($failedTest)))
->append($message)
ThomasLandauer marked this conversation as resolved.
Show resolved Hide resolved
->write();

if ($failedTest instanceof ScenarioDriven) {
Expand Down