rudexpunx's avatar

My tests run super slow

When I run testsuite for my seo forum on Homestead machine, it looks like this:

PHPUnit 6.3.0 by Sebastian Bergmann and contributors.

................................................................. 65 / 65 (100%)


Time: 47.5 seconds, Memory: 132.00MB

OK (65 tests, 135 assertions)

When I run them on my local machine, it takes forever:

PHPUnit 6.3.0 by Sebastian Bergmann and contributors.

................................................................. 65 / 65 (100%)


Time: 11.68 minutes, Memory: 124.00MB

OK (65 tests, 135 assertions)

Using Laravel 5.5 and RefreshDatabase trait.

With DatabaseTransactions it's faster (takes like 15 seconds on Homestead, still forever locally), but can't really use DatabaseTransactions as MySQL doesn't support nested transactions, so I am getting Doctrine\DBAL\Driver\PDOException: SQLSTATE[42000]: Syntax error or access violation: 1305 SAVEPOINT trans2 does not exist when Doctrine tries to create savepoints.

Was trying hard to use SQLite, but it's not possible either, as there are some weird limitations, so I'd have to recreate my migrations (to exclude adding multiple columns to a table at once, nullable/default stuff and so on).

Is there a way for me to speed up my testsuite, so I can run it under 10s for 100 tests from my local machine?

Thank you very much!

0 likes
2 replies
shawnyv's avatar

Have you disabled Xdebug on your local machine?

That big a discrepancy suggests to me that you're running with xdebug enabled, which creates a HUGE slowdown.

rudexpunx's avatar

@shawnyv xdebug disabled.

I have installed Valet, it takes ~1 minute using RefreshDatabase, but it's incredibly fast with DatabaseTransaction and the local database. If there was a way to get rid of the problem mentioned above, that would be amazing.

Currently, situation with Laravel testing is a big problem for us. If we were running complete set of tests (500+), no one would ever run them, as it takes forever.

Please or to participate in this conversation.