How to PestPHP tests in a specific order?

515 views Asked by At

Looking at the Pest documentation seems that there is no way to run test in a specific order, except renaming file with something like "01_Auth...", "02_Organization...". This doens't seem a standard or correct way to run tests that depend on others.

At the moment I have the following test files:

Feature
├── AuthTest.php
├── OrganizationTest.php
└── UserTest.php

So Pest will run tests in the following order:

1. AuthTest.php
2. OrganizationTest.php
3. UserTest.php

But I need to run tests in that order, since some tests depends on others:

1. UserTest.php
2. AuthTest.php
3. OrganizationTest.php

This is the flow:

UserTest.php register users on the database and AuthTest.php tries to authenticate with those Users. In order to create an Organization, it's necessary that there is at least 1 user associated, so it must be run after UserTest.php

How can I achieve this result in a standard way?

0

There are 0 answers