Unittest.TestCase中的setUp方法是否知道下一個將要執行的測試用例是什麼?例如:從unittest.TestCase的setUp方法知道當前的測試用例嗎?
import unittest
class Tests(unittest.TestCase):
def setUp(self):
print "The next test will be: " + self.next_test_name()
def test_01(self):
pass
def test_02(self):
pass
if __name__ == '__main__':
unittest.main()
這樣的代碼應該產生在執行時:
The next test will be: test_01
The next test will be: test_02
你試試?它工作嗎? –
「has no attribute next_test_name」 – Melon
爲什麼你需要知道這一點? – Vader