诱惑框架的nose插件
nose-allure-plugin的Python项目详细描述
用法
nosetests --with-allure --logdir=/path/to/put/results nosetests --with-allure --logdir=/path/to/put/results --not-clear-logdir
选项“–not clear logdir”对于选项“–processes”很有用,可以防止在测试结束时清除logdr。
支持的功能
附件
在测试报告中附加一些内容:
importnosedeftest_foo():nose.allure.attach('my attach','Hello, World')
步骤
将测试分为几个步骤:
importnosedeftest_foo():withnose.allure.step('step one'):# do stuffwithnose.allure.step('step two'):# do more stuff
也可以用作装饰。默认情况下,步骤名由方法名生成:
importnose@nose.allure.stepdefmake_test_data_foo():# do stuffdeftest_foo():assertmake_some_data_foo()isnotNone@nose.allure.step('make_some_data_foo')defmake_some_data_bar():# do another stuffdeftest_bar():assertmake_some_data_bar()isnotNone
环境
您可以提供测试environment parameters如报表名称、浏览器或测试服务器地址来吸引测试报表。
importnosedeftest_dummy():nose.allure.environment(report='Allure report',browser=u'Firefox')
严重性
任何测试、类或模块都可以标记为不同的严重性:
importnoseclassTestBar(object):@nose.allure.severity(nose.allure.severity_level.CRITICAL)deftest_bar(self):pass# custom severity@nose.allure.severity("hard")deftest_bar(self):pass
以具体优先级运行测试:
nosetests my_tests/ --with-allure --logdir=tmp --severity="critical, hard"
问题
可以为测试设置问题。
importnose@nose.allure.issue('http://jira.lan/browse/ISSUE-1')deftest_foo():assertFalse
功能和故事
特色和故事可以设置为测试。
importnose@nose.allure.feature('Feature1')@nose.allure.story('Story1')deftest_minor():assertFalseclassTestBar(object):@nose.allure.feature('Feature2')@nose.allure.story('Story1')deftest_bar(self):pass
按功能或故事运行测试:
nosetests my_tests/ --with-allure --logdir=tmp --feature="Feature1, Feature2" nosetests my_tests/ --with-allure --logdir=tmp --feature="Feature1, Feature2" --story="Story1, Story2"