Declaration of TestCase::setUp() must be compatible
Jan 02, 2021 Janaki Mahapatra, PHP
If you are getting an error while testing in laravel as PHP Fatal error: Declaration of Tests\TestCase::setUp() must be compatible with Illuminate\Foundation\Testing\TestCase::setUp():.... in that case, fix your test as below
Normally it happened because of PHP Unit 8 incompatibility issue. If you suddenly upgrade your Laravel version, you might have a high chance to face this issue.
class UserTest extends TestCase
{
public function setUp(): void // add void here
{
parent::setUp();
}
}
* make sure to add void in setUp method