phpunit: Can't run non-first test class in test file
Q | A |
---|---|
PHPUnit version | 8.5.2 |
PHP version | 7.4.2 |
Installation Method | Composer |
Summary
No tests executed when try to run non-first test class in a test file
Current behavior
“No tests executed!” result message
How to reproduce
Create file MyTest.php with several test classes like
<?php
use PHPUnit\Framework\TestCase;
class TestFirst extends TestCase
{
public function testOne()
{
static::assertTrue(true);
}
public function testTwo()
{
static::assertTrue(true);
}
}
class TestSecond extends TestCase
{
public function testOne()
{
static::assertFalse(false);
}
}
Run command from cli
/usr/bin/php vendor/phpunit/phpunit/phpunit --no-configuration --filter TestSecond MyTests.php
Expected behavior
TestSecond test should be run
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 19 (15 by maintainers)
TBH, there should only ever be one (test) class declared in a file. I think I will deprecate support for multiple test case classes declared in a source file in PHPUnit 9 and remove support for it in PHPUnit 10. This should make things even simpler.
Even better. 😃