From 5fb18af2456fe4841e05ea2a4b470fd886ab5da3 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 8 Mar 2023 11:58:36 -0800 Subject: [PATCH] Update testing documentation --- TESTING.md | 41 +++++++++++++++-------------------------- 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/TESTING.md b/TESTING.md index 8a430d498e..74d2ebd999 100644 --- a/TESTING.md +++ b/TESTING.md @@ -1,25 +1,17 @@ -# Using the Test Suite +# Running the Test Suite -This document is targeted at developers looking to make modifications to -this application's code base and want to run the existing test suite. +This document is targeted at developers looking to make modifications to this application's code base and want to run the existing test suite. +Before starting, follow the [instructions](README.md#installation) for installing the application locally and ensure you can load it in a browser properly. -## Setup +## Unit and Feature Tests -Follow the instructions for installing the application locally, -making sure to have also run the [database migrations](link to db migrations). +Before attempting to run the test suite copy the example environment file for tests and update the values to match your environment: +`cp .env.testing.example .env.testing` +> Since the data in the database is flushed after each test it is recommended you create a separate mysql database for specifically for tests -## Unit Tests - -The application will use values in the `.env.testing` file located -in the root directory to override the -default settings and/or other values that exist in your `.env` files. - -Make sure to modify the section in `.env.testing` that has the -database settings. In the example below, it is connecting to the -[MariaDB](link-to-maria-db) server that is used if you install the -application using [Docker](https://docker.com). +Here is an example of what your `.env.testing` file might look like: ```dotenv # -------------------------------------------- @@ -27,19 +19,18 @@ application using [Docker](https://docker.com). # -------------------------------------------- DB_CONNECTION=mysql DB_HOST=127.0.0.1 -DB_DATABASE=snipeit +DB_DATABASE=snipeit_testing DB_USERNAME=root DB_PASSWORD=changeme1234 ``` -To run the entire unit test suite, use the following command from your terminal: +Now you are ready to run the entire test suite from your terminal: -`php artisan test --env=testing` +`php artisan test` -To run individual test files, you can pass the path to the test that -you want to run. +To run individual test files, you can pass the path to the test that you want to run: -`php artisan test --env=testing tests/Unit/AccessoryTest.php` +`php artisan test tests/Unit/AccessoryTest.php` ## Browser Tests @@ -52,11 +43,9 @@ Before attempting to run Dusk tests copy the example environment file for Dusk a **Important**: Dusk tests cannot be run using an in-memory SQLite database. Additionally, the Dusk test suite uses the `DatabaseMigrations` trait which will leave the database in a fresh state after running. Therefore, it is recommended that you create a test database and point `DB_DATABASE` in `.env.dusk.local` to it. -### Test Setup +### Running Browser Tests -Your application needs to be configured and up and running in order for the browser -tests to actually run. When running the tests locally, you can start the application -using the following command: +Your application needs to be configured and up and running in order for the browser tests to actually run. When running the tests locally, you can start the application using the following command: `php artisan serve`