安装插件
pip install allure-pytest
查看 Allure 版本
allure --version
标记用法
BDD样式的标记装饰器
@allure.feature
@allure.story
story是feature的子集
代码演示:
import allure
def test_without_any_annotations_that_wont_be_executed():
pass
@allure.story('epic_1')
def test_with_epic_1():
pass
@allure.story('story_1')
def test_with_story_1():
pass
@allure.story('story_2')
def test_with_story_2():
pass
@allure.feature('feature_2')
@allure.story('story_2')
def test_with_story_2_and_feature_2():
pass
没有加标记装饰器的报告:
加上装饰器的报告:
优先级(严重程度)标记装饰器
@ allure.severity
BLOCKER = 'blocker'
CRITICAL = 'critical'
NORMAL = 'normal'
MINOR = 'minor'
TRIVIAL = 'trivial'
严重程度最高blocker,最低trivial
@allure.severity(allure.severity_level.NORMAL)
class TestClassWithNormalSeverity(object):
def test_inside_the_normal_severity_test_class(self):
pass
测试用例多了优先级severity属性
指定运行某个story或者feature案例
pytest tests.py --allure-stories story_1,story_2
pytest tests.py --allure-features feature2 --allure-stories story2
|