【发布时间】:2012-04-12 13:59:30
【问题描述】:
我想针对我的一个测试用例执行一些详尽的测试(例如,创建一个文档,以调试我遇到的一些奇怪的事情......)
我的残酷力量是使用Popen 或os.system 在循环中发射python manage.py test myapp,但现在我又回到了纯粹的方式?.....
def SimpleTest(unittest.TestCase):
def setUp(self):
def test_01(self):
def tearDown(self):
def suite():
suite = unittest.TestCase()
suite.add(SimpleTest("setUp"))
suite.add(SimpleTest("test_01"))
suite.add(SimpleTest("tearDown"))
return suite
def main():
for i in range(n):
suite().run("runTest")
我跑了python manage.py test myapp,我得到了
File "/var/lib/system-webclient/webclient/apps/myapps/tests.py", line 46, in suite
suite = unittest.TestCase()
File "/usr/lib/python2.6/unittest.py", line 216, in __init__
(self.__class__, methodName)
ValueError: no such test method in <class 'unittest.TestCase'>: runTest
我已经用谷歌搜索了错误,但我仍然一无所知(我被告知要添加一个空的 runTest 方法,但这听起来根本不对...)
嗯,根据python的unittest.TestCase:
最简单的 TestCase 子类将简单地覆盖 runTest() 方法来执行特定的测试代码
如您所见,我的全部目标是运行我的SimpleTest N 次。我需要跟踪 N 的通过、失败。
我有什么选择?
谢谢。
【问题讨论】:
-
多次运行它有什么意义?您在寻找比赛条件吗?
-
@AlexLebedev 是的,我相信这是我的意图。我遇到了这个偶尔发生的“神秘错误”。我想提供它与网络无关。我知道这不是一个公平的单元测试。根据文档,我认为有一种方法可以告诉测试后有多少是可以的,有多少是失败的。但我不确定是否有正确的方法来做我想做的事。
-
会parameterized.expand 帮忙吗?
标签: django unit-testing django-testing django-unittest