Should API calls be fetched in setUpBeforeClass() in PHPUnit tests for efficiency?

Fetching API calls in setUpBeforeClass() in PHPUnit tests can be efficient in certain scenarios, especially when the API calls are required for multiple test methods within the test class. This approach can help reduce redundant API calls and improve the overall performance of the test suite. However, it's important to ensure that the API responses are not modified or affected by other test methods, as they are fetched only once during the setUpBeforeClass() method execution.

class APITest extends \PHPUnit\Framework\TestCase
{
    protected static $apiResponse;

    public static function setUpBeforeClass(): void
    {
        self::$apiResponse = // Fetch API data here
    }

    public function testAPICall1()
    {
        // Use self::$apiResponse in test method
    }

    public function testAPICall2()
    {
        // Use self::$apiResponse in another test method
    }
}