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

Confusing warning message "Class ... cannot be found " when class does not extend TestCase #5364

Closed
ciaranmcnulty opened this issue May 18, 2023 · 1 comment
Assignees
Labels
feature/test-runner CLI test runner type/bug Something is broken version/9 Something affects PHPUnit 9 version/10 Something affects PHPUnit 10

Comments

@ciaranmcnulty
Copy link
Contributor

Q A
PHPUnit version 10.1.3
PHP version 8.2.3
Installation Method Composer

Current behavior

When a *Test.php class exists but does not extend TestCase, the warning emitted is:

Class $classname cannot be found in $path

This is confusing because there is a valid class at that path, so the user spends time checking namespace match, autoloader configuration etc.

How to reproduce

Create a class /tests/Foo.php:

<?php

namespace Foo;

class FooTest
{
}

Warning when running PHPUnit:

There was 1 PHPUnit test runner warning:

1) Class FooTest cannot be found in /Users/ciaranmcnulty/Code/phpunit-repro/tests/FooTest.php

Expected behavior

The text can be improved something like:

1) Class FooTest at /Users/ciaranmcnulty/Code/phpunit-repro/tests/FooTest.php is not a TestCase
@ciaranmcnulty ciaranmcnulty added type/bug Something is broken version/10 Something affects PHPUnit 10 version/9 Something affects PHPUnit 9 labels May 18, 2023
@ciaranmcnulty
Copy link
Contributor Author

I guess this case would need to throw a different (new) exception

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/bug Something is broken version/9 Something affects PHPUnit 9 version/10 Something affects PHPUnit 10
Projects
None yet
Development

No branches or pull requests

2 participants