[英]RSpec collection without running tests
有沒有辦法觸發 RSpec 測試用例收集,但不運行測試?
在 Python 的 pytest 中,相當於附加了一個--collect-only
開關。
我的用例:我想運行一個鈎子來驗證有關我們的測試用例的一些元數據,例如強制執行強制標記模式,我想將此驗證檢查作為 PR 檢查包含在內。 問題是,我真的不希望測試套件運行,但我只想驗證測試用例元數據。
任何幫助將不勝感激,並提前感謝您!
似乎沒有內置的方法只能進行收集。 相反,我必須在我的spec_helper
添加以下spec_helper
。 基本上,如果您將環境變量CONTEXT=validate
傳遞到您的測試運行中,則跳過測試。 這不是一個很好的方法,但似乎 RSpec 沒有提供內置的替代方案:
config.around(:each) do |example|
# validate test case metadata. Ensure proper folder structure and team tagging
# No need to run tests during validation, so they are skipped and left in 'pending' state
if CONTEXT == 'validate'
puts '[INFO] Skipping spec run and validating spec'
example.skip
validate_spec(example)
else
example.run
end
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.