2
A
回答
0
您可以隨時嘗試將測試保存爲函數,並在try/except循環中運行它。嘗試/除了將允許您在失敗後繼續。循環將允許您控制運行測試的次數。
def test(variables go here):
if __name__ == '__main__':
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(MyForms))
dateTimeStamp = time.strftime('%Y%m%d_%H_%M_%S')
buf = file("../TestReport" + "_" + dateTimeStamp + ".html", 'wb')
runner = HTMLTestRunner.HTMLTestRunner(
stream = buf,
title = 'PDFFiller tests', # Title of report
description = 'Test results' # Description of report
)
runner.run(suite)
VariableMarkerOfTestStatus = 0 #This variable is just a way of telling if the test failed or not
#tempCounter = 0 #UNCOMMENT IF YOU WANT TO LIMIT THE NUMBER OF TIMES THIS RUNS
while VariableMarkerOfTestStatus < 1: #This will loop until it passes.
try: test(variables go here)
except: VariableMarkerOfTestStatus -=1
#UNCOMMENT IF YOU WANT TO LIMIT THE NUMBER OF TIMES THIS RUNS
#if VariableMarkerOfTestStatus < 0:
# tempCounter+=1
# if tempCounter > 2: # 2 represents the number of times the test is allowed to fail
# test(variables go here) # If it has failed twice, run it once more so that the error displays
#
VariableMarkerOfTestStatus+=1
相關問題
- 1. Grails單元測試失敗
- 2. mystyfing單元測試失敗
- 3. 單元測試不失敗
- 4. Umbraco單元測試失敗
- 5. 單元測試Assert.AreEqual失敗
- 6. 單元測試失敗8
- 7. Ruby單元測試 - 訪問測試結果(成功/失敗)?
- 8. Android:如何使單元測試失敗
- 9. 簡單方程失敗單元測試
- 10. 簡單的android單元測試失敗
- 11. 如果testng單元測試用例失敗,那麼竹編就會失敗
- 12. 如果Django的中繼單元測試失敗會怎麼辦?
- 13. 如果通過rake運行,則首次單元測試失敗
- 14. 失敗哈德森構建單個單元測試失敗
- 15. QCoreApplication中的ASSERT失敗:簡單的QT單元測試失敗?
- 16. 在單個單元測試失敗時失敗TFS構建
- 17. Rspec單元測試用例失敗
- 18. 隨機單元測試失敗
- 19. 單元測試失敗,出現sys.exit
- 20. Zend Framework單元測試失敗assertResponseCode(200)
- 21. 單元測試AngularJS控制器失敗
- 22. 單元測試失敗 - 爲什麼?
- 23. PHP APC在單元測試中失敗
- 24. Ruby「耙測試:單元」失敗
- 25. 角單元測試失敗HttpClient請求
- 26. Rails的單元測試失敗
- 27. 空測試單元失敗消息
- 28. Django的單元測試:assertEqual便()失敗
- 29. 非關鍵單元測試失敗
- 30. Grails Spock單元測試一直失敗?
爲什麼不修複測試呢? – Veedrac 2014-09-27 12:13:16
我不明白爲什麼它有時失敗,有時不會。它總是不同的測試。 – Michael 2014-09-27 12:29:18
@Michael:你仍然必須明白,因爲它可能表明你的代碼中有一個短暫的錯誤。忽略有時失敗的單元測試不是一個好策略。 – 2014-09-27 12:30:21