天道酬勤,学无止境

gherkin

Using proper grammar in Gherkin

问题 查找有关 Gherkin 的文档似乎非常困难,所以我想知道是否有办法增加步骤定义以使测试人员能够使用正确的语法。 一个说明我的意思的例子是: ...Testing... Then I see there is 1 item ...More testing... Then I see there are 2 items 显然,这两个步骤将使用相同的代码。 我定义了一个这样的步骤定义,它几乎可以工作: Then(/^I see there (is|are) (\d+) item(s)?$/) do |item_count| ...code... end 除了问题是它将is/are和可选的复数s解释为参数。 有什么方法可以向 Gherkin 发出信号,表明这些只是为了允许正确的语法? 回答1 /^I see there (?:is|are) (\d+) item(?:s)?$/ 回答2 这些步骤不必使用相同的代码。 相反,他们可以调用相同的代码。 如果你应用这种模式,你就可以专注于你的步骤,只做他们应该做的一件事,那就是使用表达良好的自然语言来触发代码。 所以 ... module ItemStepHelper def see_items(count:) ... end World ItemStepHelper Then 'I see there is one item' do

2022-05-16 18:05:04    分类:技术分享    syntax   cucumber   gherkin

Using proper grammar in Gherkin

It seems to be very difficult to look up documentation about Gherkin, so I was wondering if there was a way to augment step definitions to enable the tester to use proper grammar. One example that shows what I mean is: ...Testing... Then I see there is 1 item ...More testing... Then I see there are 2 items Obviously, these two steps would use the same code. I defined a step definition like this which almost works: Then(/^I see there (is|are) (\d+) item(s)?$/) do |item_count| ...code... end Except the problem is that it interprets is/are and the optional plural s as arguments. Is there any way

2022-04-29 08:51:55    分类:问答    syntax   cucumber   gherkin

Unable to create .feature file in Pycharm Community

问题 我已经安装了Pycharm 社区版并使用以下命令安装了行为 1.2.5 。 pip install behave 它已成功安装,并且可以在Pycharm 项目解释器中使用,如下所示。 但是当我右键单击项目时,我没有看到创建 .feature 文件(Gherkin 文件)的选项 我在这里错过了什么吗,在 Pycharm 专业版中,默认情况下 Behave BDD 可用。 如何配置 Pycharm 社区的行为。 回答1 回答2 如何在 PyCharm 上安装小黄瓜插件 您可以通过Ctrl + Alt + s访问设置并安装小黄瓜插件。 我就是这么做的,而且帮了很多忙。

2022-04-28 09:09:49    分类:技术分享    python   pycharm   gherkin   python-behave

SpecFlow/Cucumber/Gherkin - Using tables in a scenario outline

Hopefully I can explain my issue clearly enough for others to understand, here we go, imagine I have the two following hypothetical scenarios: Scenario: Filter sweets by king size and nut content Given I am on the "Sweet/List" Page When I filter sweets by | Field | Value | | Filter.KingSize | True | | Filter.ContainsNuts | False | Then I should see : | Value | | Yorkie King Size | | Mars King Size | Scenario: Filter sweets by make Given I am on the "Sweet/List" Page When I filter sweets by | Field | Value | | Filter.Make | Haribo | Then I should see : | Value | | Starmix | These scenarios are

2022-04-26 14:31:36    分类:问答    cucumber   automated-tests   specflow   gherkin

Using Background title as Background in cucumber

Let's say I use Background feature which has the below steps: Background: My pre-requisites Given Step one When Step Two Then Step Three .... Then Step Fifteen So basically my Background has 15 common steps that is required for a set of scenario to run. My question is : Is it possible to use the Background title My pre-requisites in other feature files, instead of writing down all the 15 steps as Background? Or is there any other way to handle this more gracefully.

2022-04-17 05:09:52    分类:问答    selenium   automation   cucumber   bdd   gherkin

Dealing with a large string in Gherkin with Scenario Outline

I'm using Behat for BDD and using Scenario Outlines so I can easily do the same test with other data. But I got a problem with large texts. See example below: Scenario Outline: create a thing When I click on "New" Then I should be at "/thing/new" When I fill in "title" with <title> When I fill in "description" with "description" When I click on "save" Then I should be at "/things" Then I should see <title> in the list When I click on <title> Then I should see <title> Then I should see <description> Examples: | title | description | | "My new thing" | "a very large string a very large string a

2022-04-16 06:20:31    分类:问答    bdd   behat   gherkin

How can I specify arguments in the middle of the sentence in gherkin-style tests in robot framework?

Using Robot Framework, I am intent on using Gherkin style tests since it is the lingua franca of BDD/ATDD. I can specify a test like this: *** Test Cases *** New alert Given there were no alerts so far When there is an alert Then an alert should be sent with level LOW and Robot will map this to methods in my test library without any help: def there_were_no_alerts_so_far(self): assert(self.alert == None) def there_is_an_alert(self): self.alert = self.alert_processor.alert() def an_alert_should_be_sent_with_level(self, level): assert_not_none(self.alert ) assert_equal(self.alert.level.name

2022-04-04 05:34:12    分类:问答    robotframework   gherkin

CustomDataProvider for feature file (QAF)

I'm using QAF and it's amazing tool, but i have one problem. Are there any ways to parameterize cucumber feature steps with custom data provider as it's done in BDD files? For example, we can insert data from external file Examples: {'datafile':'resources/testdata.txt'} In .BDD it's done like this: SCENARIO: Data provider with testng method argument and context META-DATA: {"dataProvider":"dp-with-testngmethod-contex", "dataProviderClass":"com.qmetry.qaf.automation.impl.CustomDataProvider"} # Comment '${value}' END

2022-04-04 03:40:37    分类:问答    java   cucumber   gherkin   dataprovider   qaf