allure-codeception
allure-codeception copied to clipboard
When updating codeception to version 5.0.7 and allure-framework/allure-codeception v2.1.0, a problem appears with running tests
When updating codeception/codeception to version 5.0.7 and allure-framework/allure-codeception to v2.1.0, we encountered an issue with running tests. The configuration of extensions is as per GitHub.
extensions:
enabled:
- Qameta\Allure\Codeception\AllureCodeception
config:
Qameta\Allure\Codeception\AllureCodeception:
deletePreviousResults: true
outputDirectory: allure-results
ignoredAnnotations:
- env
- dataProvider
- skip
In the previous version, there was a method called _initialize responsible for initializing the extension.
/**
* {@inheritDoc}
*
* @throws ConfigurationException
* phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
*/
public function _initialize(): void
{
QametaAllure::reset();
$this->testLifecycle = null;
$this->threadDetector = null;
QametaAllure::getLifecycleConfigurator()
->setStatusDetector(new StatusDetector(new DefaultStatusDetector()))
->setOutputDirectory($this->getOutputDirectory());
foreach ($this->getLinkTemplates() as $linkType => $linkTemplate) {
QametaAllure::getLifecycleConfigurator()->addLinkTemplate($linkType, $linkTemplate);
}
$this->callSetupHook();
}
In the new version, a subscription to the module event has been introduced (not an extension).
protected static array $events = [
Events::MODULE_INIT => 'moduleInit',
Events::SUITE_BEFORE => 'suiteBefore',
Events::SUITE_AFTER => 'suiteAfter',
Events::TEST_START => 'testStart',
Events::TEST_FAIL => 'testFail',
Events::TEST_ERROR => 'testError',
Events::TEST_INCOMPLETE => 'testIncomplete',
Events::TEST_SKIPPED => 'testSkipped',
Events::TEST_SUCCESS => 'testSuccess',
Events::TEST_END => 'testEnd',
Events::STEP_BEFORE => 'stepBefore',
Events::STEP_AFTER => 'stepAfter'
];
private ?ThreadDetectorInterface $threadDetector = null;
private ?TestLifecycleInterface $testLifecycle = null;
/**
* {@inheritDoc}
*
* @throws ConfigurationException
* phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
*/
public function moduleInit(): void
{
QametaAllure::reset();
$this->testLifecycle = null;
$this->threadDetector = null;
QametaAllure::getLifecycleConfigurator()
->setStatusDetector(new StatusDetector(new DefaultStatusDetector()))
->setOutputDirectory($this->getOutputDirectory());
foreach ($this->getLinkTemplates() as $linkType => $linkTemplate) {
QametaAllure::getLifecycleConfigurator()->addLinkTemplate($linkType, $linkTemplate);
}
$this->callSetupHook();
}
That’s why the extension is not being initialized in the test and fails with an error. How should the extension be configured correctly for it to work?
[Qameta\Allure\Exception\OutputDirectoryUndefinedException]
Output directory is not set for Allure. Please call Qameta\Allure\Allure::setOutputDirectory() method before accessing Allure lifecycle object.
Hello, @ildream96 ! Could you please set a breakpoint inside moduleInit
and check if it's called before an exception is thrown? And please provide full trace for the exception, if possible.
@remorhaz Hello! Could you please check out #124? This issue is still reproducable, at least on the latest versions of Codeception, so I think it is not that bad to get back to _initialize
method instead of event.
@remorhaz hi. I have the same problem, do you have any update here? I suggest apply #124 because there isn't event with module.init and don't call in code
@remorhaz The same for me and I am with the guys about decision #124 . What is approximate time to have an actual code with the fix?
As I can see for extension don't have hook/event https://github.com/Codeception/Codeception/blob/29391610ff4d70bdff340970af0b9de12a34ad74/src/Codeception/Extension.php#L82
https://github.com/Codeception/Codeception/blob/29391610ff4d70bdff340970af0b9de12a34ad74/src/Codeception/Subscriber/ExtensionLoader.php#L73