mirror of
https://github.com/SuiteCRM/SuiteCRM.git
synced 2026-03-02 19:16:58 -05:00
Test suite should be run in random order #3610
Labels
No labels
Area: API
Area: Campaigns
Area: Cases
Area: Clean Up
Area: Clean Up: Performance
Area: Dashlets
Area: Databases
Area: Developer Tools
Area: Elasticsearch
Area: Elasticsearch
Area: Emails
Area: Emails:Campaigns
Area: Emails:Cases
Area: Emails:Compose
Area: Emails:Config
Area: Emails:Templates
Area: Environment
Area: Installation
Area: Language
Area: Mobile
Area: Module
Area: PDFs
Area: PHP8
Area: Reports
Area: Studio
Area: Styling
Area: Upgrading
Area: Workflow
Area:Activity Stream
Area:Calls
Area:Import
Area:Projects
Area:Search
Area:Surveys
Area:Themes
Area:Users
Branch:Hotfix
Good First Issue
Hacktoberfest
Help Wanted
PR:Community Contribution
PR:Type:Enhancement
Priority:Critical
Priority:Important
Priority:Moderate
Severity: Major
Severity: Minor
Severity: Moderate
Status: Requires Code Review
Status: Requires Updates
Status: Stale
Status: Team Investigating
Status:Assessed
Status:Fix Proposed
Status:Needs Assessed
Status:Requires Automated Tests
Type: Bug
Type:Deprecated
Type:Discussion
Type:Duplicate
Type:Invalid
Type:Question
Type:Suggestion
Type:Suggestion
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/SuiteCRM-SuiteCRM#3610
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @connorshea on GitHub (Mar 4, 2019).
Issue
Essentially, this: https://qualitycoding.org/random-test-order/
Expected Behavior
The test suite should be run with a randomly generated seed to guarantee that tests don't rely on each other's state (essentially, if you assume A -> B -> C -> D, and C relies on something B adds to the database – unintentionally or otherwise – C will now fail when run in isolation but not when run as part of the test suite.)
Similarly, it can cause problems when introducing new tests that mess with the existent order and reveal that tests have been unintentionally reliant on state from other tests.
It also could potentially mean that a test doesn't actually test the functionality, it's just been reliant on state that was introduced by a previous test (e.g. A creates a User and then doesn't get rid of it. B runs, and the test tries to create a User in a different way that doesn't work, but the database still has the User that A created, so B checks if there's a User in the db and passes despite the code being broken).
Actual Behavior
The tests are run without a seed, so they always run in the exact same order every time.
Possible Fix
The best fix would probably be to use Codeception's shuffle feature by setting
shuffle: truein thecodeception.ymlfile.You may want to run the test suite a few times with
shuffle: trueto see if that brings up any existing state problems that would result in random test failures. Ultimately, I'd say this'd be a significant improvement over the current situation even if it may introduce flaky tests occasionally, since it's exposing an anti-pattern.Steps to Reproduce
Look at Travis CI logs and note that the tests are always run in the same order, and that the test runner reports the seed as being blank.
@Dillon-Brown commented on GitHub (Mar 6, 2019):
Very much agreed, I think this will take some time before we can implement it successfully though. Our Travis builds are failing pretty randomly as it is.
@connorshea commented on GitHub (Mar 6, 2019):
Have you looked at the docs on risky tests? It seems like it could be useful to enable some of these to make sure the tests aren't messing with global scope and such: https://phpunit.de/manual/6.5/en/risky-tests.html
@lazka commented on GitHub (Mar 27, 2019):
I'v tried to improve the phpunit tests for this in #7113.
Not motivated by random order, but because many tests failed if run separately and not as part of the whole test suite. But the solution is the same.