Repository navigation
Dev: Ensure tests are run in random #9968
Description
PHP Version
8.5.0
CodeIgniter4 Version
4.7.1-dev
Per ChatGPT, tests need to run in random to enjoy the following benefits:
✔️ It reveals hidden dependencies
✔️ Forces true test isolation
✔️ Prevents flaky, misleading test results
✔️ Makes your test suite production-realistic
This issue has been initially tackled by #7717, but due to other complications it didn't fare well. As this is not a fairly easy task, I'm proposing we do it on pieces. Currently, our test suite runs in default order but should be random at some point (i.e., executionOrder="random").
Here's the plan, instead of one big PR changing all tests, we can do it by component (HTTP, Cache, Database, etc.). Then, after all tests run green on randomised testing, we set executionOrder in phpunit.xml to "random".
Please reference this issue for any PRs addressing pieces of this.
- API: refactor: make random-order API tests deterministic #9983
- AutoReview: test: indicate components that already pass random execution tests #10073
- Autoloader: test: indicate components that already pass random execution tests #10073
- Cache
- CLI:
- Commands
- Config
- Cookie: test: indicate components that already pass random execution tests #10073
- Database
- DataCaster
- DataConverter
- Debug
- Encryption
- Entity
- Events: test: indicate components that already pass random execution tests #10073
- Files: test: indicate components that already pass random execution tests #10073
- Filters: test: resolve service registry pollution in CSRFTest #10373
- Format: test: indicate components that already pass random execution tests #10073
- Helpers
- Honeypot
- HotReloader: test: indicate components that already pass random execution tests #10073
- HTTP: fix: resolve global state pollution causing random-order test failures in HTTP suite #10372
- I18n
- Images
- Language: test: indicate components that already pass random execution tests #10073
- Log: test: indicate components that already pass random execution tests #10073
- Pager: test: indicate components that already pass random execution tests #10073
- Publisher: test: indicate components that already pass random execution tests #10073
- RESTful: test: indicate components that already pass random execution tests #10073
- Router
- Security
- Session
- Test
- Throttle: test: indicate components that already pass random execution tests #10073
- Typography: test: indicate components that already pass random execution tests #10073
- Validation
- View: test: indicate components that already pass random execution tests #10073
Activity
neznaika0 commentedon Feb 20, 2026
I also mentioned the randomization of tests, the answer was the same - it takes a lot of time.
I can't imagine how to edit Database tests, this is the most difficult stage.
paulbalandan commentedon Feb 20, 2026
I also think randomising database tests would be the most difficult piece.
paulbalandan commentedon Apr 13, 2026
jalexiscv commentedon May 18, 2026
test(Database): fix state leaks and random-order test determinism for…
test(Database): fix state leaks and random-order test determinism for…
test(Database): fix state leaks and random-order test determinism for…
test(Database): fix state leaks and random-order test determinism for…
test(Database): fix state leaks and random-order test determinism for…
test(Database): fix state leaks and random-order test determinism for…
test(Database): fix state leaks and random-order test determinism for…