如果你还想从头学起Pytest,可以看看这个系列的文章哦!

https://www.cnblogs.com/poloyy/category/1690628.html

前言

上一篇文章介绍了两种allure的特性

  • @allure.description() :添加测试用例描述,一共三种方式哦!
  • @allure.title():指定测试用例标题,默认是函数名哦!

这一篇幅,我们主要来讲解最后三个常见特性,主要是为了将allure报告和测试管理系统集成,可以更快速的跳转到公司内部地址

  • @allure.link()
  • @allure.issue()
  • @allure.testcase()

先看看三个装饰器源码

def link(url, link_type=LinkType.LINK, name=None):
return safely(plugin_manager.hook.decorate_as_link(url=url, link_type=link_type, name=name)) def issue(url, name=None):
return link(url, link_type=LinkType.ISSUE, name=name) def testcase(url, name=None):
return link(url, link_type=LinkType.TEST_CASE, name=name)

知识点

  • issue()和testcase()其实调用的也是link(),只是link_type不一样
  • 必传参数 url:跳转的链接
  • 可选参数 name:显示在allure报告的名字,如果不传就是显示完整的链接;建议传!!不然可读性不高
  • 可以理解成:三个方法是一样的,我们都提供跳转链接和名字,只是链接的type不一样,最终显示出来的样式不一样而已【type不一样,样式不一样】
  • 如果你喜欢,只用@allure.link()也可以
  • 而出现三个装饰器的原因是为了更好地将链接分类【访问连接、Bug链接、测试用例链接】

看完源码和知识点,其实我们就没必要针对三个方法都展开来讲了,直接上代码,看报告的样式区别!

代码栗子

#!/usr/bin/env python
# -*- coding: utf-8 -*- """
__title__ =
__Time__ = 2020-04-18 17:01
__Author__ = 小菠萝测试笔记
__Blog__ = https://www.cnblogs.com/poloyy/
""" import allure TEST_CASE_LINK = 'https://github.com/qameta/allure-integrations/issues/8#issuecomment-268313637' @allure.link('https://www.youtube.com/watch?v=4YYzUTYZRMU')
def test_with_link():
pass @allure.link('https://www.youtube.com/watch?v=Su5p2TqZxKU', name='点击我看一看youtube吧')
def test_with_named_link():
pass @allure.issue('140', 'bug issue链接')
def test_with_issue_link():
pass @allure.testcase(TEST_CASE_LINK, '测试用例地址')
def test_with_testcase_link():
pass

运行结果,查看allure报告

@allure.link()不传name参数时的样式

不传name的话,如果链接很长,可读性就比较差啦! 

@allure.link()传了name参数时的样式

@allure.testcase()的样式

其实跟link()没有太大区别.....

@allure.issue()的样式

多了个虫子哈哈哈哈

总结

  • 为了减少程序的阅读复杂性,其实可以统一用@allure.link()
  • 传name,写好链接描述,就知道这个链接是干嘛的啦,反正三个装饰器的作用都是一样的,就是样式略微不同.....

Pytest系列(22)- allure的特性,@allure.link()、@allure.issue()、@allure.testcase()的详细使用的更多相关文章

  1. Pytest系列(13)- 重复执行用例插件之pytest-repeat的详细使用

    如果你还想从头学起Pytest,可以看看这个系列的文章哦! https://www.cnblogs.com/poloyy/category/1690628.html 前言 平常在做功能测试的时候,经常 ...

  2. Pytest系列(21)- allure的特性,@allure.description()、@allure.title()的详细使用

    如果你还想从头学起Pytest,可以看看这个系列的文章哦! https://www.cnblogs.com/poloyy/category/1690628.html 前言 前面介绍了两种allure的 ...

  3. Pytest系列(20)- allure结合pytest,allure.step()、allure.attach的详细使用

    如果你还想从头学起Pytest,可以看看这个系列的文章哦! https://www.cnblogs.com/poloyy/category/1690628.html 前言 allure除了支持pyte ...

  4. Pytest系列(23)- allure打标记,@allure.feature()、@allure.story()、@allure.severity()的详细使用

    如果你还想从头学起Pytest,可以看看这个系列的文章哦! https://www.cnblogs.com/poloyy/category/1690628.html 前言 前面几篇文章主要介绍了all ...

  5. Pytest 系列(29)- 详解 allure.dynamic 动态生成功能

    如果你还想从头学起Pytest,可以看看这个系列的文章哦! https://www.cnblogs.com/poloyy/category/1690628.html 前言 @allure.title  ...

  6. pytest(12)-Allure常用特性allure.attach、allure.step、fixture、environment、categories

    上一篇文章pytest Allure生成测试报告我们学习了Allure中的一些特性,接下来继续学习其他常用的特性. allure.attach allure.attach用于在测试报告中添加附件,补充 ...

  7. pytest系列(二):筛选用例新姿势,mark 一下,你就知道。

    pytest系列(一)中给大家介绍了pytest的特性,以及它的编写用例的简单至极. 那么在实际工作当中呢,我们要写的自动化用例会比较多,不会都放在一个py文件里. 如下图所示,我们编写的用例存放在不 ...

  8. 9.9 翻译系列:数据注解特性之--MaxLength 【EF 6 Code-First系列】

    原文链接:https://www.entityframeworktutorial.net/code-first/maxlength-minlength-dataannotations-attribut ...

  9. 9.3 翻译系列:数据注解特性之Key【EF 6 Code-First 系列】

    原文链接:http://www.entityframeworktutorial.net/code-first/key-dataannotations-attribute-in-code-first.a ...

随机推荐

  1. ECShop 2.x/3.x SQL注入/任意代码执行漏洞

    poc地址:https://github.com/vulhub/vulhub/blob/master/ecshop/xianzhi-2017-02-82239600/README.zh-cn.md 生 ...

  2. java时间工具类型,格式化时间,最近7天 月初 月末 季度 月度 时间格式化 等等

    package com.tz.util; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util. ...

  3. .Netcore HttpClient源码探究

    源码搜索与概述 搜索HttpClient源码 https://source.dot.net/#System.Net.Http/System/Net/Http/HttpClient.cs 1.HttpC ...

  4. 53. 最大子序和(剑指 Offer 42)

    53. 最大子序和(剑指 Offer 42) 知识点:数组:前缀和:哨兵:动态规划:贪心:分治: 题目描述 输入一个整型数组,数组中的一个或连续多个整数组成一个子数组.求所有子数组的和的最大值. 要求 ...

  5. 35岁Android程序员被阿里辞退,生活压力太大痛哭,中年危机如何自救?

    多数人都喜欢安逸的生活,尤其是随着年龄的增长,很多人都希望工作和生活趋于稳定,不愿意再让生活有很大的变动.可是,当达到一定的年龄时,危机还是存在的. 之前有一位阿里员工在脉脉上,晒出了自己被辞退的经历 ...

  6. Bootstrap Blazor 更新版本 5.6.0

    Bootstrap Blazor 是一款基于 Bootstrap 的 企业级 Blazor UI 组件库,目前内置近 90 个组件,欢迎大家尝试使用.本次更新全面升级支持 Bootstrap V5.6 ...

  7. 《手把手教你》系列技巧篇(十六)-java+ selenium自动化测试-元素定位大法之By xpath下卷(详细教程)

    1.简介 按宏哥计划,本文继续介绍WebDriver关于元素定位大法,这篇介绍定位倒数二个方法:By xpath.xpath 的定位方法, 非常强大.  使用这种方法几乎可以定位到页面上的任意元素. ...

  8. MobSF移动安全扫描平台环境搭建与试用

    MobSF简介 MobSF(Mobile-Security-Framework)是一种开源自动化的移动应用程序(Android / iOS / Windows)安全测试框架,能够执行静态,动态和恶意软 ...

  9. Matlab 使用filter求解系统响应

    MATLAB 提供了函数filter,可以实现差分方程的递规求解. 设差分方程的形式为\(a_0y(n) + a_1y(n-1) + \cdots + a_my(n-m)=b_0x(n)+b_1x(n ...

  10. Redmine Notes

    Mandatory authenticaion: login as Administrator, Settings -> Authentication -> Check "Aut ...