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

When updating codeception to version 5.0.7 and allure-framework/allure-codeception v2.1.0, a problem appears with running tests #123

Closed
ildream96 opened this issue Dec 12, 2023 · 5 comments

Comments

@ildream96
Copy link

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.
@remorhaz
Copy link
Contributor

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.

@AtCliffUnderline
Copy link
Contributor

@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.

@beliarh0503
Copy link

beliarh0503 commented Apr 18, 2024

@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

@manifity
Copy link

@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?

remorhaz added a commit to remorhaz/allure-codeception that referenced this issue May 14, 2024
remorhaz added a commit to remorhaz/allure-codeception that referenced this issue May 14, 2024
beliarh0503 pushed a commit to beliarh0503/allure-codeception that referenced this issue May 15, 2024
beliarh0503 pushed a commit to beliarh0503/allure-codeception that referenced this issue May 15, 2024
remorhaz added a commit to remorhaz/allure-codeception that referenced this issue May 16, 2024
remorhaz added a commit to remorhaz/allure-codeception that referenced this issue May 16, 2024
beliarh0503 added a commit to beliarh0503/allure-codeception that referenced this issue May 22, 2024
remorhaz added a commit to remorhaz/allure-codeception that referenced this issue May 25, 2024
@baev baev closed this as completed in 8399110 May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants