python-behave - Python表现Gherkin Step参数获取编译时间数字预期异常
问题描述
Feature: Step Parameter Test
Scenario: look up a book
Given I search for a valid book
Then the result page will include "success"
Scenario: look up an invalid book
Given I search for a invalid book
Then the result page will include "failure"
步骤定义:获取 {} 之间预期的异常编号,不考虑状态作为参数
@then('the result page will include {status}')
def step_impl(context,status):
"""
:type context: behave.runner.Context
"""
pass
在这种情况下,我什至尝试了正则表达式来获取步骤未定义的异常。没有找到任何方法将字符串/数字/双精度作为参数从功能文件中传递
请建议是否有办法解决这个问题。
解决方案
无论出于何种原因,您的behave
解析器似乎都是're'
. 通常是'parse'
. 在您的测试文件中添加以下内容:
from behave import use_step_matcher
use_step_matcher('parse')
#the rest of your test here
#@given...
behave
文档在use_step_matcher
这里。
推荐阅读
- rust - 一个独立的闭包可以接受 `&str` 并以相同的生命周期返回 `&str` 吗?
- macos - Error opening "Electron" on Mac OS Big Sur 11.2.3. What to do?
- javascript - MSAL 2.0 AD Login Popup Shows Previous Logged User Name Instead Of New User Name
- python - convert dataframe column from timestamp with timezone to timestamp type
- c# - SSIS script task build error related to mscorlib
- android - What is the name of this component in Xamarin Forms and how can I change its color?
- google-cloud-platform - Google Cloud SDK Support Deadline
- php - 如果变量为空,让我的 div 消失?
- python - 递归生成器的基本情况:yield 或 return
- pytorch - 旧版 torchtext 0.9.0