Using either php please test
or php artisan test
to run feature tests, I am finding that the Statamic cache is being built from scratch each time, causing very high load times for each test.
As an example, if I load /my_url
in the web browser for the first time, it takes 6s to load but if I run it a second time, it takes 530ms because everything is already cached, just as you would expect with Statamic.
However, consider this very simple test:
use Tests\TestCase;
class ThingyTest extends TestCase
{
/**
* A basic feature test example.
*
* @return void
*/
public function test_example()
{
$response = $this->get('/my_url');
$response->assertStatus(200);
}
}
This literally takes 6s every time I run it. So it would quickly become impossible to do effective TDD if I wrote tests for my entire application.
I'm also struggling to find up-to-date reference material about testing in Statamic. The v2 docs has https://v2.statamic.com/testing but the referenced Statamic\Testing\TestCase
doesn't appear to exist in v3 and there doesn't seem to be any information in the v3 docs about testing at all. I was hoping that there would just be something like a --with-cache
flag I could use but apparently there isn't.