This normally happens when the framework hasn't been booted. In most cases, you're extending the wrong TestCase class. If you extend the PHPUnit base TestCase class the framework isn't booted.
Worked for me adding parent::setUp(); in public function setUp():
abstract class TestCase extends BaseTestCase
{
public function setUp(): void
{
parent::setUp();
// Do your extra thing here
}
}