You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We the RefreshDatabase (with plans to move to LazilyRefreshDatabase) trait in our feature tests.
There are a few test cases that feel like they should be moved into separate cases.
We've achieved this in some of our test's by removing the trait and using the @depends annotation to ensure we can pass data down a chain of tests.
However, this creates issues when running tests in random order.
PHPUnit will retain the order of a chain of dependant tests, but cases have risen where the entire test chain is the first to run, meaning the database is empty (causing the test to fail)
Another workaround is keeping the RefreshDatabase trait, but calling DB:commit() prior to the first test finishing.
Whilst this works, it feels like it's the wrong solution (since it pollutes the DB for the other tests)
I, therefore, propose adding some checks to the RefreshDatabase (and LazilyRefreshDatabase) traits to detect a dependant chain and prevent the rollback of the DB.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
We the
RefreshDatabase
(with plans to move toLazilyRefreshDatabase
) trait in our feature tests.There are a few test cases that feel like they should be moved into separate cases.
We've achieved this in some of our test's by removing the trait and using the
@depends
annotation to ensure we can pass data down a chain of tests.However, this creates issues when running tests in random order.
PHPUnit will retain the order of a chain of dependant tests, but cases have risen where the entire test chain is the first to run, meaning the database is empty (causing the test to fail)
Another workaround is keeping the RefreshDatabase trait, but calling
DB:commit()
prior to the first test finishing.Whilst this works, it feels like it's the wrong solution (since it pollutes the DB for the other tests)
I, therefore, propose adding some checks to the
RefreshDatabase
(andLazilyRefreshDatabase
) traits to detect a dependant chain and prevent the rollback of the DB.Happy to take a crack at the dev this one!
Beta Was this translation helpful? Give feedback.
All reactions