Allure测试框架,测试报告美化与定制
终端执行:
pytest test_allure_feature.py --allure-features="登录模块" -vs ---》执行具体feature
pytest test_allure_feature.py --allure-stories="登录成功" -vs ---执行具体stories
pytest test_allure_feature.py --allure-stories="登录失败" -vs
pytest test_allure_feature.py --allure-features="登录模块" -vs --alluredir=./result1 --生成测试报告
allure serve ./result1 ---启动allure查看测试报告
代码1:
import pytestimport allure @allure.feature("搜索模块")class TestSearch(): def test_case1(self): print("case1") def test_case1(self): print("case2") @allure.feature("登录模块")class TestLogin(): @allure.story("登录成功") def test_login_sucess(self): with allure.step("步骤1:打开应用"): print("打开应用") with allure.step("步骤2:进入登录页面"): print("登录页面") with allure.step("步骤3:输入用户名和密码"): print("输入用户名和密码") print("这是登录:测试用例,登录成功") @allure.story("登录失败") def test_login_sucess_a(self): print("这是登录:测试用例,登录失败")
关联测试链接:
终端:
步骤1:pytest test_case.py --alluredir ./result2 --执行测试生成报告文件
步骤2:allure generate ./result2 ---报告文件生成html查看文件到默认文件allure-report里
步骤2:allure generate ./result2 -o report2 --报告文件生成html文件到指定文件report2里
代码2:
import allure TEST_CASE_LINK='https://www.sekorm.com/'@allure.testcase(TEST_CASE_LINK,"测试链接")def test_with_testcase_link(): pass
终端执行:
pytest test_severity.py --allure-severities="normal" -vs --执行指定级别的测试用例
代码3
@allure.severity(allure.severity_level.TRIVIAL)def test_with_trivial_severity(): pass @allure.severity(allure.severity_level.NORMAL)def test_with_normal_severity(): pass @allure.severity(allure.severity_level.NORMAL)class TestClassWithNormalSeverity(object): def test_inside_the_normal_severity_test_class(self): pass @allure.severity(allure.severity_level.CRITICAL) def test_inside_the_normal_severity_test_class_with_overriding_critical_severity(self): pass if __name__ == '__main__': pytest.main()
赞 (0)