Feature: 标注主要功能模块
Story: 标注Features功能模块下的分支功能
Severity: 标注测试用例的重要级别
Step: 标注测试用例的重要步骤
Issue和TestCase: 标注Issue、Case,可加入URL
import allure import pytest @allure.feature(‘test_module_01‘) def test_case_01(): """ 用例描述:Test case 01 """ assert 0
import allure import pytest @allure.feature(‘test_module_01‘) @allure.story(‘test_story_01‘) def test_case_01(): """ 用例描述:Test case 01 """ assert 0
import allure import pytest
def test_login(): """ 用户登录用例 """ assert 0
Allure中对严重级别的定义:
import allure import pytest
@allure.severity(‘blocker‘) def test_login(): """ 用户登录用例 """ assert 0
import allure import pytest @allure.step(‘1.输入用户名2.输入密码3.登录‘) def test_login(): """ 用户登录用例 """ assert 0
import allure import pytest @allure.issue("http://www.baidu.com") @allure.testcase("http://www.testlink.com") def test_login(): """ 用户登录用例 """ assert 0
报告可以显示许多不同类型的提供的附件,可以补充测试,步骤或夹具结果。可以通过调用以下内容创建附件allure.attach(body, name, attachment_type, extension)
:
body
- 要写入文件的原始内容。
name
- 包含文件名的字符串
attachment_type
- 其中一个allure.attachment_type
值
extension
- 提供的将用作创建文件的扩展名。
或者allure.attach.file(source, name, attachment_type, extension)
:
source
- 包含文件路径的字符串。
(其他参数相同)
import allure
import pytest
@pytest.fixture
def attach_file_in_module_scope_fixture_with_finalizer(request):
allure.attach(‘A text attacment in module scope fixture‘, ‘blah blah blah‘, allure.attachment_type.TEXT)
def finalizer_module_scope_fixture():
allure.attach(‘A text attacment in module scope finalizer‘, ‘blah blah blah blah‘,
allure.attachment_type.TEXT)
request.addfinalizer(finalizer_module_scope_fixture)
def test_with_attacments_in_fixture_and_finalizer(attach_file_in_module_scope_finalizer):
pass
def test_multiple_attachments():
allure.attach.file(‘./cat.png‘, attachment_type=allure.attachment_type.PNG)
allure.attach(‘<head></head><body> a page </body>‘, ‘Attach with HTML type‘, allure.attachment_type.HTML)
原文:https://www.cnblogs.com/peng-lan/p/11357307.html