ExcelBDD Python指南

news2024/10/7 20:24:45

在Python里面支持BDD

Excel BDD Tool Specification By ExcelBDD Method

This tool is to get BDD test data from an excel file, its requirement specification is below

The Essential of this approach is obtaining multiple sets of test data, so when combined with Excel's Sheet, the key parameters are:

  1. ExcelFileName, required, which excel file is used.
  2. SheetName, optional, which Sheet the requirement writer writes in, if not specified, 1st sheet is chosen. An Excel file supports multiple Sheets, so an Excel is sufficient to support a wide range, such as Epic, Release, or a module.
  3. HeaderMatcher, filter the header row by this matcher, if matched, this set will be collected in.
  4. HeaderUnmatcher, filter the header row by this matcher, if matched, this set will be excluded.

Once the header row and parameter name column are determined by 'Parameter Name' grid automatically, the data area is determined, such as the green area in the table above. The gray area of the table above is the story step description, which is the general requirements step.

Install ExcelBDD Python Edition

pip install excelbdd

API

behavior.get_example_list

get_example_list(excelFile, sheetName = None, headerMatcher = None, headerUnmatcher = None)

  1. excelFile: excel file path and name, relative or absolute
  2. sheetName: sheet name, optional, default is the first sheet in excel file
  3. HeaderMatcher: filter the header row by this matcher, if matched, this set will be collected in. optional, default is to select all.
  4. HeaderUnmatcher: filter the header row by this matcher, if matched, this set will be excluded. optional, default is to exclude none.

behavior.get_example_table

get_example_table(excelFile,sheetName = None,headerRow = 1,startColumn = 'A')

  1. excelFile: excel file path and name, relative or absolute
  2. sheetName: sheet name, optional, default is the first sheet in excel file
  3. headerRow: the number of header row, optional, default is 1
  4. startColumn: the char of first data area, optional, default is column A in sheet

Simple example code

The Famouse FizzBuzz kata is described in excelbdd format, as below.

import pytest
from excelbdd.behavior import get_example_list
import FizzBuzz

excelBDDFile = "path of excel file" 
@pytest.mark.parametrize("HeaderName, Number1, Output1, Number2, Output2, Number3, Output3, Number4, Output4",
                        get_example_list(excelBDDFile,"FizzBuzz"))
def test_FizzBuzz(HeaderName, Number1, Output1, Number2, Output2, Number3, Output3, Number4, Output4):
    assert FizzBuzz.handle(Number1) == Output1
    assert FizzBuzz.handle(Number2) == Output2
    assert FizzBuzz.handle(Number3) == Output3
    assert FizzBuzz.handle(Number4) == Output4

 Input vs Expect + Test Result Format - SBT - Specification By Testcase

 

testcase example is below, which uses headerMatcher to filter the data

@pytest.mark.parametrize("HeaderName, ParamName1, ParamName1Expected, ParamName1TestResult, \
                         ParamName2, ParamName2Expected, ParamName2TestResult, ParamName3, \
                         ParamName3Expected, ParamName3TestResult, ParamName4, ParamName4Expected, \
                         ParamName4TestResult",
                        get_example_list(bddFile1, "SBTSheet1","Scenario"))
def test_excelbdd_sbt(HeaderName, ParamName1, ParamName1Expected, ParamName1TestResult, 
                      ParamName2, ParamName2Expected, ParamName2TestResult, ParamName3, 
                      ParamName3Expected, ParamName3TestResult, ParamName4, ParamName4Expected, 
                      ParamName4TestResult):
    print(HeaderName, ParamName1, ParamName1Expected, ParamName1TestResult, 
                      ParamName2, ParamName2Expected, ParamName2TestResult, ParamName3, 
                      ParamName3Expected, ParamName3TestResult, ParamName4, ParamName4Expected, 
                      ParamName4TestResult)
    # add test data are loaded into the above parameters, add test code below

 ExcelBDD can detect 3 parameter-header patterns automatically, the last one is below.

Input vs Expected 

 

The demo code is below

@pytest.mark.parametrize("HeaderName, ParamName1, ParamName1Expected,  \
                         ParamName2, ParamName2Expected, ParamName3, \
                         ParamName3Expected, ParamName4, ParamName4Expected"
                        get_example_list(bddFile1, "SBTSheet1","Scenario"))
def test_excelbdd_sbt(HeaderName, ParamName1, ParamName1Expected,  
                      ParamName2, ParamName2Expected, ParamName3, 
                      ParamName3Expected, ParamName4, ParamName4Expected):
    print(HeaderName, ParamName1, ParamName1Expected, 
                      ParamName2, ParamName2Expected,  ParamName3, 
                      ParamName3Expected, ParamName4, ParamName4Expected)
    # add test data are loaded into the above parameters, add test code below

Get Table

The test data are organized in normal table, as below.

 the below code show how to fetch the test data into testcase

from excelbdd.behavior import get_example_table

@pytest.mark.parametrize("Header01, Header02, Header03, Header04, Header05, Header06, Header07, Header08",
                         get_example_table(tableFile, "DataTable4"))
def test_get_example_tableB(Header01, Header02, Header03, Header04, Header05, Header06, Header07, Header08):
    print(Header01, Header02, Header03, Header04, Header05, Header06, Header07, Header08)   
    # add test data are loaded into the above parameters, add test code below

ExcelBDD Python指南线上版维护在ExcelBDD Python Guideline

ExcelBDD开源项目位于 ExcelBDD Homepageicon-default.png?t=N7T8https://dev.azure.com/simplopen/ExcelBDD

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1090619.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

GoLand 2023.2.3(go语言开发)

GoLand是一款由JetBrains开发的集成开发环境(IDE),专门针对Go语言进行优化和集成。以下是GoLand的主要功能: 智能代码编辑器:GoLand的智能代码编辑器可以提供代码补全、语法高亮、自动纠错、代码导航等一系列功能&…

数字通信测量仪器5201数据网络测试仪

数字通信测量仪器 5201数据网络测试仪 Ceyear 5201数据网络测试仪配置1Gbps、10Gbps、25Gbps、40Gbps、50Gbps、100Gbps和400Gbps高密度测试模块,是一款多速率、多端口、可扩展的高性能数据网络测试仪。本产品构建了高性能IP基础测试硬件平台,提供L2-L3…

npm install报--4048错误和ERR_SOCKET_TIMEOUT问题解决方法之一

一、问题描述 学习vue数字大屏加载动漫效果时,在项目终端页面输入全局下载指令 npm install -g json-server 问题1、报--4048错误 会报如下错误 operation not permitted......errno: -4048code:EPERMsyscall: mkdir......The operation was reiected by your op…

我们又组织了一次欧洲最大开源社区活动,Hugging Face 博客欢迎社区成员发帖、Hugging Chat 功能更新!...

每一周,我们的同事都会向社区的成员们发布一些关于 Hugging Face 相关的更新,包括我们的产品和平台更新、社区活动、学习资源和内容更新、开源库和模型更新等,我们将其称之为「Hugging News」。本期 Hugging News 有哪些有趣的消息&#xff0…

Maven Surefire Exclude 无效问题排查日志

昨天有个需求,要在单元测试的时候单线程执行,并且只执行单元测试类特殊结尾的,那么根据以往经验,直接在maven里面配置exclude并且指定include即可。如下尝试 <plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-surefire-plugin&…

selenium打开火狐浏览器

项目上需求为&#xff1a;甲方OA 系统是IE系统&#xff0c;需要从IE系统点个按钮打开火狐浏览器单点登录跳转到我们的系统 前期解决方案为&#xff1a;打开浏览器就行了&#xff0c;然后就用的是打开本地浏览器&#xff0c;但是由于B/S架构&#xff0c;有别人远程访问我的ip来…

专业音视频领域中,Pro AV的崛起之路

编者按&#xff1a;在技术进步的加持下&#xff0c;AV行业发展得如何了&#xff1f;本文采访了两位深耕于广播电视行业的技术人&#xff0c;为我们介绍了专业音视频的进展&#xff1a;一位冉冉升起的新星&#xff1a;Pro AV以及FPGA在其中发挥的作用。 美国&#xff0c;拉斯维加…

【Linux】:常见指令理解(3)

17.grep指令 grep参考文档 语法&#xff1a; grep [选项] 搜寻字符串 文件 功能&#xff1a; 在文件中搜索字符串&#xff0c;将找到的行打印出来 常用选项&#xff1a; -i &#xff1a;忽略大小写的不同&#xff0c;所以大小写视为相同 -n &#xff1a;顺便输出行号 -v &…

GoLang连接mysql数据库

跟着文档走GORM 指南 | GORM - The fantastic ORM library for Golang, aims to be developer friendly. 1.使用命令拉取 go get -u gorm.io/gorm go get -u gorm.io/driver/sqlite2.开始使用 package mainimport ("fmt""github.com/gin-gonic/gin"&…

什么是SRE?它与 DevOps 有何关系?

SRE 代表站点可靠性工程。它建立在DevOps 原则之上,为 IT 运营带来工程主导的方法。SRE 使用软件来自动化系统操作、识别问题并实施解决方案。 SRE 的概念是在 Google 开发的。它基于这样的理念:代码和软件是管理大型系统的最有效方法。由单独团队启动的手动程序存在监督和不…

智能网关IOT 2050采集应用

SIMATIC IOT2050 是西门子公司新推出的应用于企业数字化转型的智能边缘计算和云连接网关。 它将云、公司内 IT 和生产连接在一起&#xff0c;专为直接在生产环境中获取、处理和传输数据的工业 IT 解 决方案而设计。例如&#xff0c;它可用于将生产 过程与基于云的机器和生产数据…

项目和1013

这里写目录标题 项目采用Nginx做反向代理、以及搭建Tomcat服务器集群&#xff0c;实现负载均衡和动静分离4.34.7相关的八股 动静分离4.125-4 Redis集中式缓存商品详情页5-7 开启本地缓存5-11 开启本地缓存 采用RabbitMQ实现异步消息扣减数据库内库存7-4 同步进缓存&#xff0c;…

java生成自定义长度的唯一随机字符串

思路 基于唯一数字&#xff0c;再随机指向ASCII码的大小写字母的编码值实现随机&#xff0c;唯一数字可以由redis自增或者雪花id等生成。实现代码 /*** description: 生成10个字符的唯一随机字符串&#xff0c;由数字大小写字母组成* date 15:58 2023/10/13* param increment…

C++ - git 命令行

为什么要有 git 你很可能遇到过这种情况&#xff0c;在写项目的时候&#xff0c;要我不符合 leader 的要求&#xff0c;因而修改了很多个版本&#xff0c;但是修改到最后一版的时候&#xff0c;leader 有觉得当前这版还没有之前 某一版好&#xff0c;现在又要求你在 之前的那一…

Fbank及MFCC学习

Fbank&#xff1a;FilterBank&#xff1a;人耳对声音频谱的响应是非线性的&#xff0c;Fbank就是一种前端处理算法&#xff0c;以类似于人耳的方式对音频进行处理&#xff0c;可以提高语音识别的性能。获得语音信号的fbank特征的一般步骤是&#xff1a;预加重、分帧、加窗、短时…

【嵌入式开发学习01】Arduino安装esp32-cam以及CameraWebServer实例的实现

目录 1. 硬件2. 软件2.1 arduino下载安装2.2 arduino配置esp32-cam开发板文件2.3 下载相应版本的esp32 3. ESP32-CAM实例&#xff1a;CameraWebServer3.1 选择开发板3.2 选择示例代码进行验证3.3 烧录进行实测 1. 硬件 没买下载主板的可使用usb转串口模块进行烧录&#xff0c;接…

LeetCode【73】矩阵置零

题目&#xff1a; 思路&#xff1a; 1、从题目看&#xff0c;在遍历数组的同时&#xff0c;如果遍历到0&#xff0c;回溯i&#xff0c;j&#xff0c;将其对应的行列变为0。不能变更后面的&#xff0c;后面遍历整个数组都将变成0. 2、需要额外的空间存储要变0的标记位&#xf…

高通推出骁龙X系列进军PC平台

今日&#xff0c;高通在官方博客发布了由高级副总裁兼首席营销官莫珂东&#xff08;Don McGuire&#xff09;署名的一篇文章&#xff0c;正式揭晓了一款全新的芯片系列&#xff1a;骁龙X系列。该款芯片专为下一代PC体验打造。高通表示&#xff0c;2024年将会是PC行业的一个拐点…

OJ项目——统一数据格式返回,我是如何处理的?

目录 前言 OJ项目中是如何处理的 1、准备一个类&#xff0c;作为统一的数据返回格式 2、准备一个类&#xff0c;实现ResponseBodyAdvice接口 3、我们如何写返回值更好 4、进一步优化返回值 小结 前言 关于SpringBoot的同一功能处理&#xff0c;本博主在这篇博客已经有介…

Linux 系统中提供CPU性能分析工具整理

Linux 系统中提供CPU性能分析工具整理 汇总 查看CPU信息 在linux操作系统中&#xff0c;CPU的信息在启动的过程中被装载到虚拟目录/proc下的cpuinfo文件中&#xff0c;我们可以通过 cat /proc/cpuinfo 查看一下&#xff1a; cat /proc/cpuinfo显示如下&#xff1a; rootthe…