testing report? Python automated testing-Allure test report usage encyclopedia, a full-through


foreword

Install and configure environment variables

Windows / Mac / Linux general installation method:
download the allure.zip installation package, and configure the environment variables after decompression:
Configuration path (windos example):
F:\Building an automated test framework from 0 to 1\allure-2.17.3\ bin

Enter allure --version on the command line, and the version description allure command line has been installed successfully.

allure --version

For use with pytest, you need to install the python plugin:

pip install allure-pytest

Allure features and syntax usage

The most important thing about the @allure.step
allure report is that it allows for a very detailed step description of each test case.
Through the @allure.step() decorator, the test case can display a more detailed test process in the allure report

@allure.step("第三步")
def nested_step():
    #具体测试步骤代码
    nested_step_with_arguments(1, 'abc')

allure.attach (very useful)
function: the allure report also supports displaying many different types of attachments, which can supplement test results; you can output whatever you want, which is very good

语法: allure.attach(body, name, attachment_type, extension)

Parameter list
body: content to be displayed (attachment)
name: attachment name
attachment_type: attachment type, one of allure.attachment_type
extension: attachment extension (rarely used)

@allure.title("前置操作:登录")
@allure.step("第二步")
def step_with_nested_steps():
    allure.attach('在fixture后置操作里面添加一个附件txt', 'fixture后置附件',
                  allure.attachment_type.TEXT)
    nested_step()
@allure.title() (用例标题)

from time import sleep
import allure
 
import pytest
@allure.title("测试:title")
@allure.description("""
这是一个@allure.description装饰器
没有特别的用处
""")
@pytest.mark.parametrize("n", list(range(5)))
class TestWeibo:
    @allure.story("子功能/单个用例名称")
    def test_case1_01(self, open_weibo, n):
        sleep(1)
        print("查看微博热搜", n)
 
    def test_case1_02(self, open_weibo, n):
        sleep(1)
        print("查看微博詹姆斯", n)

@allure.description()
Function: You can add a sufficiently detailed description of the test case.
The writing method is the same as above.

@allure.description("""
这是一个@allure.description装饰器
没有特别的用处
""")

@allure.feature("feature name")

@allure.feature("测试采购合同模块")  # 通常对测试类进行装饰
class TestPurchaseContract:

@allure.story("subfunction/single use case name")

@allure.story("测试同步标识灯功能") # 通常对单个用例进行装饰
def test_synchronize(self):
"""
测试 同步标识灯 功能
:return:
"""
r = self.pending_request.synchronize()
assert r["msg"] == "同步更新申购单红、绿、蓝灯状态成功"
assert r["success"] is True

Allure feature-severity (priority of test cases)

class Severity(object):
    BLOCKER = 'blocker'
    CRITICAL = 'critical'
    NORMAL = 'normal'
    MINOR = 'minor'
    TRIVIAL = 'trivial'

@allure.severity(“minor”)
Blocker level: interrupt defect (the client program does not respond and cannot perform the next step)
Critical level: critical defect (missing function points)
Normal level: common defect (numerical calculation error)
Minor level: Minor defects (interface errors do not match UI requirements)
Trivial level: minor defects (must-enter items have no prompts, or prompts are not standardized

allure generate report command

Execute the test command

pytest -n auto --alluredir=allure

Test report generation command

allure serve allure

report preview

B1

B2

Remarks:
Environment parameter configuration: environment.properties (need to be placed in the allure directory)

Browser=Chrome
Browser.Version=81.0.4044.92
Stand=Production
ApiUrl=pda
python.Version=3.7.2

Test category configuration file categories.json (need to be placed in the allure directory)

[
  {
    
    
    "name": "忽略测试",
    "matchedStatuses": ["skipped"]
  },
  {
    
    
    "name": "Infrastructure problems",
    "matchedStatuses": ["broken", "failed"],
    "messageRegex": ".*bye-bye.*"
  },
  {
    
    
    "name": "Outdated tests",
    "matchedStatuses": ["broken"],
    "traceRegex": ".*FileNotFoundException.*"
  },
  {
    
    
    "name": "测试失败",
    "matchedStatuses": ["failed"]
  },
  {
    
    
    "name": "测试缺陷",
    "matchedStatuses": ["broken"]
 
  }
  ,
  {
    
    
    "name": "测试成功",
    "matchedStatuses": ["passed"]
  }
]

The trend module does not display the problem Solution:
Reason: There is no history folder in the allure-result file
Solution: Manually copy the history in allure-report to the allure directory

The following is the most complete software test engineer learning knowledge architecture system diagram in 2023 that I compiled

1. From entry to mastery of Python programming

Please add a picture description

2. Interface automation project actual combat

Please add a picture description

3. Actual Combat of Web Automation Project

Please add a picture description

4. Actual Combat of App Automation Project

Please add a picture description

5. Resume of first-tier manufacturers

Please add a picture description

6. Test and develop DevOps system

Please add a picture description

7. Commonly used automated testing tools

Please add a picture description

Eight, JMeter performance test

Please add a picture description

9. Summary (little surprise at the end)

Only with unremitting pursuit can the dream soar in the blue sky and the flame of struggle light up the soul. Believe in your persistence, seize every opportunity, reap brilliance in sweat, and achieve an extraordinary life.

Only by constantly surpassing ourselves can we find infinite possibilities; only by working hard can we create our own brilliant future. Persevere in struggle and chase your dreams, and you will surely gain everything you desire!

Only struggle can light up the light of dreams, only persistence can overcome difficulties, and only bravery can surpass oneself. Believe in your own strength, keep pursuing progress, and eventually become the omnipotent person.

Guess you like

Origin blog.csdn.net/m0_70102063/article/details/131724765