2024-09-25 00:25:17 发布
网友
我想用注释@SmokeTest或@LoadTest@RegressionTest或{}来标记每个单独的测试用例。在
@SmokeTest
@LoadTest
@RegressionTest
是否可以使用提供注释的Python鼻子将每个测试用例分为以下类别之一?在
很难确切地说出您在问什么,但听起来您可能在寻找the built-in ^{} plugin 'Attrib',它允许您为测试设置属性(并根据属性选择测试组)。在
使用@attr添加属性以标记测试用例和类,并带有注释:
@attr
from nose.plugins.attrib import attr @attr(priority='first') def test_support_1(): #test details... @attr(priority='second') def test_support_2(): #test details...
运行方式:
在Python2.6及更高版本中,@attr可以在类上设置,如下所示:
@attr(priority='sanity') class MyTestCase: def test_support_1(self): pass def test_support_2(self): pass
nosetests -a priority=sanity
使用@attr添加属性。@attr如果您想运行整个类,也可以按照下面的相同方法为类设置
参考:http://nose.readthedocs.org/en/latest/plugins/attrib.html
from nose.plugins.attrib import attr @attr('smoke') def test_awesome_1(): # your test... @attr('load') def test_awesome_2(): # your test... @attr('regression') def test_awesome_3(): # your test... @attr('regression') def test_awesome_4(): # your test...
然后运行为
很难确切地说出您在问什么,但听起来您可能在寻找the built-in ^{} plugin 'Attrib' ,它允许您为测试设置属性(并根据属性选择测试组)。在
使用
@attr
添加属性以标记测试用例和类,并带有注释:运行方式:
^{pr2}$在Python2.6及更高版本中,
@attr
可以在类上设置,如下所示:运行方式:
使用
@attr
添加属性。@attr
如果您想运行整个类,也可以按照下面的相同方法为类设置参考:http://nose.readthedocs.org/en/latest/plugins/attrib.html
然后运行为
^{pr2}$相关问题 更多 >
编程相关推荐