2016-07-29 61 views
1

我的目標是獲取包/文件夾中測試方法的數量。我能夠通過執行pytest如何計數測試用例?

py.test <folder> --collect-only|grep collected

做這說明測試計數爲

collected 104 items

然而,這計數參數測試多次,e.g。如果一個方法有兩組參數,單個測試將被計數2次。 有什麼辦法可以告訴pytest將它們統計爲單個嗎?

回答

3

如何

find . -type f -name 'test*.py' -exec grep -e 'def test_' '{}' \; | wc -l 

ag 'def test_' | wc -l 
+0

由於一噸:) – pr4bh4sh