Allure use case Customization parameters and report effect display

Source: Internet
Author: User
Allure + pytest Use demo Purpose

The results of the Pytest use Case Layer test report are presented through allure customization attributes. python version and necessary libraries

Python 2.7
Pytest 3.1.3
environmental parameters in the pytest-allure-adaptor 1.7.7 Effect Chart data overview

failure use case presentation in category

Test name, ID number, priority, time consuming, description, link, test step, associated data in test suite

Time- consuming and priority in icons

Time Scale

use case function chunking display

Associated data Display

Specific example code show description

# coding:utf-8 Import pytest Import Allure # test function @allure. Step ("string add: {0},{1}") # test steps to automatically obtain function parameter def through the format mechanism STR_  Add (str1, str2): print "Hello" if not isinstance (str1, str): Return '%s is not a string '% str1 if not               Isinstance (str2, str): Return '%s is not a string '% str2 return str1 + str2 @allure. Severity ("Critical") # priority, including blocker, critical, normal, minor, trivial several different levels @allure. Feature ("Test Module _demo1") # feature block, Featu Re function is larger than story, that is, when both feature and story are present, feature is the parent node @allure. Story ("Test Module _demo2") # feature block, use cases with same feature or story will be normalized to the same module , which can be used to filter @allure. Issue ("Bug number: 123") # Problem table Knowledge, association identifies existing problems, can be a URL link address @allure. testcase ("Use case name: test string equality") # use case  Identification, association identification use case, can be a URL link address @pytest. mark.parametrize ("Para_one, Para_two", # Use case parameters [("Hello
                         World ", Hello World"), # Parameterized data for use case parameters (4, 4), ("Chinese", "Chinese")], Ids=["Test ASCII string ", # The Use case name" test digital string "for the application parameterized data,
    "Test Unicode string"] def test_case_example (Para_one, Para_two): "" "Use Case Description: Test string equality:p Aram Para_one: Parameter 1 :p Aram Para_two: Parameter 2 "" "# get the parameter paras = VARs () # The Environment parameter in the report, can be used for the description of the necessary environment parameters, after the same parameter is the quasi-allure.environment ( Host= "172.6.12.27", Test_vars=paras) # associated with the information, you can record the necessary information in the report Allure.attach ("Use case parameters", "{0}". Format (paras)) #
    Call Test Function res = Str_add (Para_one, Para_two) # Back up the necessary test intermediate result data Allure.attach ("Str_add return results", "{0}". Format (RES)) # test steps to explain the necessary test procedures with pytest.allure.step ("Test step 2, result checksum {0} = = {1}". Format (res, para_one+para_two)): Assert R Es = = para_one+para_two, res if __name__ = = ' __main__ ': # Execute, specify execute test module _DEMO1, test module _demo2 two modules, and specify execution case priority for CRITICAL,BL
 Ocker pytest.main (['--allure_stories= test module _demo1, test module _demo2 ', '--allure_severities=critical, Blocker '])

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.