用途:test-executor 是一个测试执行技能,围绕 pytest 提供系统化的测试运行能力,覆盖单元测试、集成测试和端到端测试,并支持配置、并行执行、测试筛选与报告生成。
主要能力:可发现并统计测试(如 pytest --collect-only);按文件、函数、类、方法或 -k 模式运行指定测试;用 -m 按标记筛选(如 not slow、smoke);通过 pytest-xdist 并行执行(pytest tests/unit/ -n auto);用 --durations 分析慢测试;用 --pdb、-l、--tb 等调试失败;用 --lf、--ff 重跑失败用例;生成 JUnit XML、HTML、JSON 报告;结合覆盖率与 CI/CD 运行。
使用方式:典型命令包括 pytest tests/unit/ -v、pytest tests/ --cov=src --cov-report=term-missing、pytest tests/ --junitxml=reports/junit.xml --cov=src --cov-report=xml --cov-fail-under=80 -v,以及 pytest tests/unit/ -n auto。配置可写入 pytest.ini 或 pyproject.toml,定义 testpaths、markers、addopts 与覆盖率选项。
适用场景:本地快速反馈、提交前检查、CI/CD 全量测试、调试失败用例、性能与并行优化。
限制:资料以 pytest 为主,未提供其他测试框架的适配说明;部分命令依赖 pytest-xdist、pytest-html、pytest-json-report 等插件,需另行安装;具体项目环境、依赖与数据库服务需自行准备。