codeigniter4 / codeigniter4/CodeIgniter4

Dev: Ensure tests are run in random

未關閉
#9,968 4 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視
dev help wanted testing
主要語言
PHP
星號
6k
分支
2k
平均合併
1 天 16 小時
30 天內合併 PR
81

描述

### PHP Version

8.5.0

### CodeIgniter4 Version

4.7.1-dev

Per [ChatGPT](https://chatgpt.com/s/t_69985949e68c8191af967ca124b1b7f7), 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.

- [x] API: #9983
- [x] AutoReview: #10073
- [x] Autoloader: #10073
- [ ] Cache
- [x] CLI:
- #9998
- #10014
- [ ] Commands
- [ ] Config
- [x] Cookie: #10073
- [ ] Database
- [ ] DataCaster
- [ ] DataConverter
- [ ] Debug
- [ ] Email
- [ ] Encryption
- [ ] Entity
- [x] Events: #10073
- [x] Files: #10073
- [x] Filters: #10373
- [x] Format: #10073
- [ ] Helpers
- [ ] Honeypot
- [x] HotReloader: #10073
- [x] HTTP: #10372
- [ ] I18n
- [ ] Images
- [x] Language: #10073
- [x] Log: #10073
- [x] Pager: #10073
- [x] Publisher: #10073
- [x] RESTful: #10073
- [ ] Router
* #9967
- [x] Security
- #9969
- #10073
- [ ] Session
- [ ] Test
- [x] Throttle: #10073
- [x] Typography: #10073
- [ ] Validation
- [x] View: #10073

貢獻指南

開啟貢獻指南

研究方向

先從 phpunit.xml 和 issue 中列出的未勾選元件區域開始,然後使用 executionOrder="random" 執行相關的 PHPUnit 測試,以識別執行順序相依性。選定元件的測試能在隨機順序下通過且不存在隱藏相依性,即表示完成;當所有列出的區域都為綠色,且 phpunit.xml 使用隨機執行時,更廣泛的工作即告完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
php
領域
testing
Issue 類型
重構
難度
4/5
預估耗時
3-5 天
活躍度
冷清
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。