Closed huangdijia closed 3 weeks ago
The issue you're facing is due to the way Pest and PHPUnit handle grouping for test cases. The line uses()->group('mygroup')->in(DIR.'/MyGroup'); in Pest.php is intended to apply Pest's grouping mechanism to all Pest tests in the specified directory. However, it does not automatically apply to PHPUnit tests unless they explicitly use the @group annotation.
Solution To ensure your PHPUnit tests are recognized as part of the mygroup group, you need to explicitly add the @group annotation to your test methods. Here is how you can structure your test case:
Example:
use PHPUnit\Framework\TestCase;
class ExampleTest extends TestCase
{
/**
* @group mygroup
*/
public function test_the_application_returns_a_successful_response()
{
$this->assertTrue(true);
}
}
What Happened
How to Reproduce
ExampleTest.php
andUnitTest.php
is the cases of PHPUnit.Sample Repository
No response
Pest Version
v2.34.7
PHP Version
8.1.28
Operation System
macOS
Notes
No response