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

Deprecate multiple test case classes in a single file #4105

Closed
realFlowControl opened this issue Feb 17, 2020 · 1 comment
Closed

Deprecate multiple test case classes in a single file #4105

realFlowControl opened this issue Feb 17, 2020 · 1 comment
Labels
feature/test-runner CLI test runner type/deprecation Something will be/is deprecated
Milestone

Comments

@realFlowControl
Copy link
Sponsor Contributor

Hey there,

it is stated in the ChangeLog-9.0.md file that

Multiple test case classes (classes that extend TestCase) that are declared in a single sourcecode file are no longer supported

This is only true for files included directly as in:

$ phpunit path/to/FooTest.php

but it is still possible to have multiple and randomly named test classes in that FooTest.php when invoked via

$ phpunit path/to/

This is because invoking with a directory (or suite from config.xml) the StandardSuiteLoader is not used.

Proposal: I would create a PR that deprecates this behavior and prints out warnings if the file has more than one test case class in it or the test case class is not named like the filename as it is already behaving when invoking with a filename.

Very curious on your opinion.

/Flo

@realFlowControl realFlowControl added the type/enhancement A new idea that should be implemented label Feb 17, 2020
@sebastianbergmann sebastianbergmann added feature/test-runner CLI test runner type/deprecation Something will be/is deprecated and removed type/enhancement A new idea that should be implemented labels Feb 17, 2020
@sebastianbergmann
Copy link
Owner

Go ahead. Thanks!

realFlowControl added a commit to realFlowControl/phpunit that referenced this issue Feb 19, 2020
realFlowControl added a commit to realFlowControl/phpunit that referenced this issue Feb 19, 2020
realFlowControl added a commit to realFlowControl/phpunit that referenced this issue Feb 19, 2020
@sebastianbergmann sebastianbergmann added this to the PHPUnit 9.1 milestone Mar 31, 2020
stronk7 added a commit to stronk7/moodle that referenced this issue Mar 11, 2021
Custom autoloaders are deprecated with PHPUnit 9 and will be removed
with PHPUnit 10.

Since PHPUnit 8.5 custom autoloaders don't do much because that
version removed the ability to launch unit tests by class name
and that's exactly the reason we had a custom autoloader (to map
class names to files within our tests). See MDL-67673 about
when direct use of classes was deprecated (8.5), now removed (9.5).

So, as far as it's unused, removing it now, test still can be
selectively using any of:

- a relative path to file (although there are some restrictions comming
  with PHPUnit 9, see sebastianbergmann/phpunit#4105
- using --filter, to point to any classname[::method]
- using --testsuite to run a complete suite
- using --config to point to custom components.

Also, commented out the lib/ajax/tests directory because it doesn't
exist / is empty and PHPUnit 9 emits error when a configured test
directory does not exist. See
sebastianbergmann/phpunit#4493.

Alternative was to completely remove the configuration line, but
decided to keep it around in case some day we want to add some
test there.
stronk7 added a commit to stronk7/moodle that referenced this issue Mar 11, 2021
Custom autoloaders are deprecated with PHPUnit 9 and will be removed
with PHPUnit 10.

Since PHPUnit 8.5 custom autoloaders don't do much because that
version removed the ability to launch unit tests by class name
and that's exactly the reason we had a custom autoloader (to map
class names to files within our tests). See MDL-67673 about
when direct use of classes was deprecated (8.5), now removed (9.5).

So, as far as it's unused, removing it now, test still can be
selectively using any of:

- a relative path to file (although there are some restrictions comming
  with PHPUnit 9, see sebastianbergmann/phpunit#4105
- using --filter, to point to any classname[::method]
- using --testsuite to run a complete suite
- using --config to point to custom components.

Also, commented out the lib/ajax/tests directory because it doesn't
exist / is empty and PHPUnit 9 emits error when a configured test
directory does not exist. See
sebastianbergmann/phpunit#4493.

Alternative was to completely remove the configuration line, but
decided to keep it around in case some day we want to add some
test there.
athos-ribeiro added a commit to athos-ribeiro/BaconQrCode that referenced this issue Jun 24, 2023
Having phpunit test classes not matching their file names has been
deprecated since phpunit 9 and was removed in phpunit 10.

* sebastianbergmann/phpunit#4105
* sebastianbergmann/phpunit#4621 (comment)
athos-ribeiro added a commit to athos-ribeiro/BaconQrCode that referenced this issue Jun 24, 2023
Having phpunit test classes not matching their file names has been
deprecated since phpunit 9 and was removed in phpunit 10.

* sebastianbergmann/phpunit#4105
* sebastianbergmann/phpunit#4621 (comment)
* Fixes: Bacon#97
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/test-runner CLI test runner type/deprecation Something will be/is deprecated
Projects
None yet
Development

No branches or pull requests

2 participants