You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Test Kitchen中运行Github仓库里的指定Inspec测试子集?

可行!这里有两种方法实现只运行指定子目录的Inspec测试

完全可以实现只运行common和master目录下的Inspec测试,下面是两种最直接的方案:

方法1:在kitchen.yml中指定具体子目录的Git路径

Test Kitchen支持通过Git URL的子路径语法,直接引用外部仓库里的特定目录作为Inspec测试源。你只需要修改inspec_tests配置,把原来指向整个仓库的地址,拆分成两个指向对应子目录的条目:

inspec_tests:
  - git::https://github.com/your-username/your-inspec-repo.git//common
  - git::https://github.com/your-username/your-inspec-repo.git//master

这里的//是关键语法——它告诉Test Kitchen:从这个Git仓库拉取后,只使用//后面指定的子目录作为Inspec测试的根目录。

方法2:在独立仓库中创建一个聚合Profile(可选)

如果希望更灵活地管理测试集合,可以在你的独立Inspec仓库根目录下创建一个新的Profile(比如命名为core-tests),在它的inspec.yml中添加对common和master的依赖引用:

name: core-tests
depends:
  - name: common
    path: ./common
  - name: master
    path: ./master

然后在kitchen.yml里只引用这个聚合Profile的Git路径:

inspec_tests:
  - git::https://github.com/your-username/your-inspec-repo.git//core-tests

这种方式适合后续需要调整测试集合的场景,只需要修改聚合Profile的依赖即可,不用改动kitchen.yml。

无论用哪种方法,运行kitchen verify时,Test Kitchen都会只执行你指定的common和master目录下的测试,完全忽略worker目录的内容。

内容的提问来源于stack exchange,提问作者Yegolev

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.07 13:07:54