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

[WIP] Improvements for multi-app setup #6569

Open
wants to merge 4 commits into
base: 4.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 25 additions & 6 deletions ext/Recorder.php
Expand Up @@ -3,6 +3,7 @@
namespace Codeception\Extension;

use Codeception\Event\StepEvent;
use Codeception\Event\SuiteEvent;
use Codeception\Event\TestEvent;
use Codeception\Events;
use Codeception\Exception\ExtensionException;
Expand Down Expand Up @@ -295,12 +296,20 @@ class Recorder extends \Codeception\Extension
/** @var string */
private $dateFormat;

public function beforeSuite()
private $isDisabled = false;

public function beforeSuite(SuiteEvent $e)
{
$this->webDriverModule = null;

if (!$e->getSuite()->count()) {
$this->isDisabled = true;
return; // skip for empty suites
}

if (!$this->hasModule($this->config['module'])) {
$this->isDisabled = true;
$this->writeln('Recorder is disabled, no available modules');

return;
}

Expand Down Expand Up @@ -331,9 +340,10 @@ public function beforeSuite()

public function afterSuite()
{
if (!$this->webDriverModule) {
if ($this->isDisabled) {
return;
}

$links = '';

if (count($this->slides)) {
Expand Down Expand Up @@ -380,7 +390,7 @@ public function afterSuite()
*/
public function before(TestEvent $e)
{
if (!$this->webDriverModule) {
if ($this->isDisabled) {
return;
}
$this->dir = null;
Expand All @@ -407,6 +417,10 @@ public function before(TestEvent $e)
*/
public function cleanup(TestEvent $e)
{
if ($this->isDisabled) {
return;
}

if ($this->config['delete_orphaned']) {
$recordingDirectories = [];
$directories = new \DirectoryIterator(codecept_output_dir());
Expand Down Expand Up @@ -445,9 +459,10 @@ public function cleanup(TestEvent $e)
*/
public function persist(TestEvent $e)
{
if (!$this->webDriverModule) {
if ($this->isDisabled) {
return;
}

$indicatorHtml = '';
$slideHtml = '';
$testName = $this->getTestName($e);
Expand Down Expand Up @@ -548,7 +563,11 @@ public function persist(TestEvent $e)
*/
public function afterStep(StepEvent $e)
{
if ($this->webDriverModule === null || $this->dir === null) {
if ($this->isDisabled) {
return;
}

if ($this->dir === null) {
return;
}

Expand Down
8 changes: 8 additions & 0 deletions src/Codeception/Subscriber/Console.php
Expand Up @@ -125,6 +125,10 @@ public function __construct($options)
// triggered for scenario based tests: cept, cest
public function beforeSuite(SuiteEvent $e)
{
if (!$e->getSuite()->count()) {
return; // skip for empty suites
}

$this->namespace = "";
$settings = $e->getSettings();
if (isset($settings['namespace'])) {
Expand Down Expand Up @@ -344,6 +348,10 @@ private function printStep(Step $step)

public function afterSuite(SuiteEvent $e)
{
if (!$e->getSuite()->count()) {
return; // skip for empty suites
}

$this->message()->width($this->width, '-')->writeln();
$messages = Notification::all();
foreach (array_count_values($messages) as $message => $count) {
Expand Down
4 changes: 4 additions & 0 deletions src/Codeception/Subscriber/Module.php
Expand Up @@ -33,6 +33,10 @@ public function beforeSuite(SuiteEvent $e)
if (!$suite instanceof Suite) {
return;
}
if (!$e->getSuite()->count()) {
$this->modules = [];
return true; // do not launch on empty suite
}
$this->modules = $suite->getModules();
foreach ($this->modules as $module) {
$module->_beforeSuite($e->getSettings());
Expand Down