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

Allow test runner extensions to disable default progress and result printing #5168

Closed
sebastianbergmann opened this issue Feb 5, 2023 · 0 comments
Assignees
Labels
feature/events Issues related to PHPUnit's event system feature/test-runner CLI test runner type/enhancement A new idea that should be implemented
Milestone

Comments

@sebastianbergmann
Copy link
Owner

sebastianbergmann commented Feb 5, 2023

Starting with PHPUnit 10 and its event system, the test runner can be extended.

To extend PHPUnit's test runner, you implement the PHPUnit\Runner\Extension\Extension interface. This interface requires a bootstrap() method to be implemented. This method is called by PHPUnit's test runner to bootstrap a configured extension. An extension is configured in PHPUnit's XML configuration file.

For test runner extensions that intend to change how the test runner presents progress information or test result information, the default progress printer and the default result printer currently have to be disabled using the --no-output, --no-progress, or --no-results CLI options.

This ticket proposes the addition of another interface, PHPUnit\Runner\Extension\OutputReplacing:

namespace PHPUnit\Runner\Extension;

interface OutputReplacing
{
    public function replacesDefaultProgressPrinter(): bool;

    public function replacesDefaultResultPrinter(): bool;
}

When implemented by a test runner extension's bootstrap class in addition to PHPUnit\Runner\Extension\Extension, the PHPUnit test runner will query the extension using these methods on whether or not the extension intends to replace the test runner's default progress printer, the test runner's default result printer, or both.

When multiple test runner extensions are configured (and therefore bootstrapped), only one may replace the test runner's default progress printer or the test runner's default result printer, respectively. The test runner will error out when more than one test runner extension intends to replace a default printer.

@sebastianbergmann sebastianbergmann added type/enhancement A new idea that should be implemented feature/test-runner CLI test runner feature/events Issues related to PHPUnit's event system labels Feb 5, 2023
@sebastianbergmann sebastianbergmann added this to the PHPUnit 10.1 milestone Feb 5, 2023
@sebastianbergmann sebastianbergmann self-assigned this Feb 5, 2023
sebastianbergmann added a commit that referenced this issue Mar 18, 2023
Co-authored-by: Sebastian Bergmann <sb@sebastian-bergmann.de>
Co-authored-by: Arne Blankerts <Arne@Blankerts.de>
Co-authored-by: Andreas Möller <am@localheinz.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/events Issues related to PHPUnit's event system feature/test-runner CLI test runner type/enhancement A new idea that should be implemented
Projects
None yet
Development

No branches or pull requests

1 participant