Back to articles
Laravel Testing Environment Setup
How-ToSystems

Laravel Testing Environment Setup

via Dev.toDennis Tabaldo

This guide explains how to properly configure a testing environment in Laravel using .env.testing and phpunit.xml. πŸ“Œ Overview When running automated tests, you should isolate your testing environment from development and production. This prevents accidental data loss and improves test reliability. βš™οΈ 1. Create .env.testing Create a .env.testing file in the root of your Laravel project: APP_NAME = laravel APP_ENV = local APP_KEY = # application key APP_DEBUG = true APP_URL = http :// laravel . test APP_LOCALE = en APP_FALLBACK_LOCALE = en APP_FAKER_LOCALE = en_US APP_MAINTENANCE_DRIVER = file BCRYPT_ROUNDS = 12 DB_CONNECTION = mysql DB_HOST = 127 . 0 . 0 . 1 DB_PORT = 3306 DB_DATABASE = # your testing database (e.g., laravel-testing) DB_USERNAME = root DB_PASSWORD = SESSION_DRIVER = database SESSION_LIFETIME = 120 SESSION_ENCRYPT = true SESSION_PATH =/ SESSION_DOMAIN = null βœ… Notes Use a separate database for testing. Never reuse your development or production database. πŸ§ͺ 2. Configure p

Continue reading on Dev.to

Opens in a new tab

Read Full Article
5 views

Related Articles