Home > Software engineering >  how to run parallel test in laravel?
how to run parallel test in laravel?

Time:11-14

I have 15 feature tests in the project. this information of env.test:

DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=test_db
DB_USERNAME=test
DB_PASSWORD=123456

when I run my test as parallel using php artisan test --parallel i get with error:

1) Tests\Feature\Settlement\PublicSTest::testCreatePublicS
Illuminate\Database\QueryException: SQLSTATE[42501]: Insufficient privilege: 7 ERROR:  permission denied to create database (SQL: create database "test_db_test_3" encoding "utf8")

how to fix this error?

CodePudding user response:

As the documentation states, Laravel will create multiple databases to avoid the parallel processes colliding with each others data.

Add the privilege for the user to create databases, assuming this is an postgres database based on the error.

Access cli

psql test_db test

Command to execute

ALTER USER test CREATEDB;
  • Related