PHPUnit Laravel database test SQLite in file vs SQLite in memory
The test runs in the setUp() method a migration and seeds with faker that creates 10 users out of user model factory and a few records for another 10 models with relationships to the user model.
The test itself only tests whether visiting the default router/page returns 200 status code and it checks if the user ID 1 exists.
It took 4.1 seconds to run the test on SQLite file database and 3.24 seconds on SQLite in-memory database.
Run time | |
---|---|
SQLite file | 4.1 seconds |
SQLite in-memory | 3.24 seconds |
Testing environment:
- OS: MacOS Mojave 10.14
- SQLite: 3.24.0
- PHP: 7.2.1 (cli)
- PHPUnit: 7.4.5