Skip to content
New issue

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

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

Already on GitHub? # to your account

Ability to write report only on explicit demand #111

Open
antonkomarev opened this issue Nov 27, 2024 · 1 comment
Open

Ability to write report only on explicit demand #111

antonkomarev opened this issue Nov 27, 2024 · 1 comment

Comments

@antonkomarev
Copy link

antonkomarev commented Nov 27, 2024

Is your feature request related to a problem? Please describe.
I want to avoid writing allure reports all the time on the developer local machine.

Describe the solution you'd like
I want to have some kind of environment or argument for the PHP CLI command to enable report writing.

Some kind like

./vendor/bin/phpunit --with-allure-report

Describe alternatives you've considered
I understand that developers might have local phpunit.xml, but it's not an easy to manage multiple configurations.

@antonkomarev antonkomarev changed the title Ability to write report only on demand Ability to write report only on explicit demand Nov 27, 2024
@antonkomarev
Copy link
Author

antonkomarev commented Nov 28, 2024

Found a workaround using lifecycle hooks:

return [
    'outputDirectory' => './tests/allure-results',
    'lifecycleHooks' => [
        new class implements BeforeTestStartHookInterface, BeforeContainerStartHookInterface {
            public function beforeContainerStart(
                ContainerResult $container,
            ): void {
                if (!$this->isReportEnabled()) {
                    $container->setExcluded(true);
                }
            }

            public function beforeTestStart(
                TestResult $test,
            ): void {
                if (!$this->isReportEnabled()) {
                    $test->setExcluded(true);

                    return;
                }
            }

            private function isReportEnabled(): bool
            {
                return boolval(getenv('ALLURE_REPORT_ENABLED'));
            }
        },
    ],
];

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant