![](/img/trans.png)
[英]how can I pass argument(s) through nose.run that can be picked up by list of python test files containing test methods
[英]How can I pass a list of unit test python file names(path\test.py) to nose.run() method to execute all the tests in all these files?
我有一個python文件名列表(名稱包括絕對路徑。例如,folder1 \\ test1.py)。 每個文件都包含一組單元測試用例。 我想將此列表傳遞給nas.run()方法,以便可以執行這些文件中的所有測試。 誰能幫我用python代碼解決這個問題。
列表中的文件不必來自同一文件夾。 給出了絕對文件路徑以及每個文件名。 如果可以保存鼻子.run()的結果,這將很有幫助。(非強制性要求)
如果所有測試都位於同一文件夾中,則可以實際運行測試,如下所示
nose.run(argv=['folder', 'test_suite1', 'test_suite2'])
其中folder
是同時存在test_suite1.py
和test_suite2.py
的文件夾。
為了捕獲運行結果,我使用了“ --debug-log”參數。 因此,您的最終命令變為
nose.run(argv=['folder', 'test_suite1', 'test_suite2', '--debug-log', '/home/loglocation/logfile.log'])
如果測試套件位於不同的位置,我沒有花太多時間在如何運行方面。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.