Flutter Patrol如何实现单文件测试单次独立执行?
Patrol集成测试实现独立非增量执行
目录结构
integration_test ├── patrol ├── 1_test.dart ├── 2_test.dart ├── 3_test.dart ├── 4_test.dart ├── 5_test.dart └── 6_test.dart
当前Windows环境运行命令
patrol test -t integration_test\patrol\
当前执行逻辑问题
当前执行时会增量叠加测试文件,导致单个测试重复运行:
--------In the loop: first test run 1_test.dart second test run 1_test.dart+ 2_test.dart third test run 1_test.dart+ 2_test.dart+ 3_test.dart fourth test run 1_test.dart+ 2_test.dart+ 3_test.dart+ 4_test.dart ... etc... last test run 1_test.dart+ 2_test.dart+ 3_test.dart+ 4_test.dart+ 5_test.dart+ 6_test.dart -------end of test- test results are displayed correctly
目前测试结果显示正常,但存在单个测试文件被重复执行的问题。
期望执行逻辑
需要实现每个测试文件独立运行一次,执行流程如下:
-In the loop: first test run 1_test.dart second test run 2_test.dart third test run 3_test.dart ... last one 6_test.dart -------end of test
解决方法
不要直接指定整个目录运行,而是逐个遍历测试文件单独执行:
CMD环境下执行命令
for %f in (integration_test\patrol\*_test.dart) do patrol test -t "%f"
PowerShell环境下执行命令
Get-ChildItem -Path integration_test\patrol\*_test.dart | ForEach-Object { patrol test -t $_.FullName }
这样就能让每个测试文件仅运行一次,不会出现增量叠加的重复执行问题。
内容的提问来源于stack exchange,提问作者Agata Olbrycht
相关产品推荐
相关产品推荐

