我试图在类似UNIX的系统上用Maven运行Cucumber(不幸的是,我不得不使用Windows,尽管cmd.exe具有相同的结果)命令行:
mvn clean test -Dcucumber.options="src/test/resources/com/example/sqa/automation_cuke/pages/sample_test.feature"
结果是:
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
...
[INFO] --- exec-maven-plugin:1.2.1:java (default) @ sqa.automation_cuke ---
Feature: My animals Sample
Sample test to use as basis for conversion
Scenario: My animals # sample_test.feature:4
Given that I have my animals
1 Scenarios (1 undefined)
1 Steps (1 undefined)
0m0.000s
You can implement missing steps with the snippets below:
@Given("^that I have my animals$")
public void that_I_have_my_animals() throws Throwable {
// Write code …Run Code Online (Sandbox Code Playgroud) 我想做的是从命令行传递黄瓜选项到执行带有标记名@extecuteThese的场景,但我也想排除标记名为@WIP的场景,所以我到目前为止做的是
-Dcucumber.options='--tags @executeThese --tags ~@WIP'
Run Code Online (Sandbox Code Playgroud)
但不幸的是,它没有考虑〜@ WIP标签选项
任何帮助,非常感谢!!
摘要:
我正在对Spring Boot应用程序使用Cucumber运行一些测试。当我使用“ mvn测试”执行它们时,我的Cucumber测试运行良好,但是在“ mvn verify”生命周期中执行它们时,我的黄瓜测试失败。
细节:
我的黄瓜赛跑者课程如下所示:
@RunWith(Cucumber.class)
@CucumberOptions(
features = {"src/test/resources/features/creditCardSummary.feature"},
glue = {"th.co.scb.fasteasy.step"},
plugin = {
"pretty",
"json:target/cucumber-json-report.json"
}
)
public class CreditCardRunnerTest {
}
Run Code Online (Sandbox Code Playgroud)
当我执行“ mvn test”时,我可以在日志中看到在maven spring boot插件实例化Spring Boot实例之前,实例化了CucumberRunner:
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running CreditCardRunnerTest
@creditcards
Feature: POST /creditcards/summary
As a user, I would like to get basic information, balance and/or last 'n' transactions of a given list of credit cards, so that I can provide the information for further operations.
........... …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Java Cucumber来使用有序的,标记的钩子。例如:
@Before(“ @ quicklink”,order = 20)
编译器似乎不喜欢它。不可能有一个带标签的有序钩子吗?似乎是功能的合理组合。如果是这样,语法是什么?
n
我试图找出是否有一个选项可以找出当前正在执行的黄瓜步骤,我试图根据步骤名称执行某些操作。
我可以看到StepDefinitionMatch类可以获取这些步骤,但是我不确定如何在运行时访问这些步骤。有什么帮助吗?如果有帮助,可以添加调用堆栈的快照。
public StepDefinitionMatch(List<Argument> arguments, StepDefinition stepDefinition, String featurePath, Step step, LocalizedXStreams localizedXStreams) {
super(arguments, stepDefinition.getLocation(false));
this.stepDefinition = stepDefinition;
this.featurePath = featurePath;
this.step = step;
this.localizedXStreams = localizedXStreams;
}
Run Code Online (Sandbox Code Playgroud)
我正在使用黄瓜数据表。我想将此数据表转换为Map而不是列表。因此,基本上,如果我将“标题行”用作键并将数据行用作键的值,该怎么办。我应该怎么做?
让我分享一个例子来更清楚。
鉴于以下动物:
| Type | BabyAnimal |
| cow | Calf |
| horse | Pony |
| sheep | Lamb |
Run Code Online (Sandbox Code Playgroud)
与其创建一个List<List<String>>here,不如创建一个List<Map<String,String>>here。地图的键应包含“类型”和“ BabyAnimal”,值应包含相应的值。因此,地图实体为:
<Type,cow>,<BabyAnimal,Calf>
<Type,horse>,<BabyAnimal,Pony>
<Type,sheep>,<BabyAnimal,Lamb>
Run Code Online (Sandbox Code Playgroud)
我们将如何做?我觉得这是一种更好的方法,因为我们正在从密钥中获取数据。例如List(1).Map.get(Type)
,在List的情况下,我们必须执行get(0),get(1),并且有使用不正确数据的机会。
我正在运行Cucumber JVM功能文件,使用Java8和PicoContainer.我已经剥离了这些步骤,因此它们是空的,我仍然会收到错误.这是我的功能:
Feature: Full Journey
Scenario: Can load a typical JIRA csv and calculate the distribution from it
Given a typical JIRA export "/closed_only_JIRA.csv"
When I import it into Montecarluni
Then I should see the distribution
"""
6, 15, 3, 14, 2, 5, 6, 8, 5, 10, 15, 4, 2, 1
"""
When I copy it to the clipboard
Then I should be able to paste it somewhere else
Run Code Online (Sandbox Code Playgroud)
(是的,这是一个完整的旅程而不是BDD方案.)
无论出于何种原因,在Kotlin中运行此步骤会导致错误:
import cucumber.api.java8.En
class ClipboardSteps(val world : World) : En …Run Code Online (Sandbox Code Playgroud) 我正在通过一些教程学习黄瓜,有些东西我不知道该怎么做..我需要制作一个依赖于另一个场景的场景(例如注销场景,我必须在注销之前先登录)所以我该怎么做?我应该在注销场景(在功能文件中)编写登录步骤,还是有一种方法可以在注销场景中调用整个登录场景
我还需要知道是否应该在每个场景之前设置驱动程序并在每个场景之后退出驱动程序?
cucumber cucumber-jvm cucumber-junit selenium-webdriver cucumber-java
我在我的功能文件中有以下示例小黄瓜场景:
Scenario: Book an FX Trade
Given trades with the following details are created:
|buyCcy |sellCcy |amount |date |
|EUR |USD |12345.67 |23-11-2017 |
|GBP |EUR |67890.12 |24-11-2017 |
When the trades are executed
Then the trades are confirmed
Run Code Online (Sandbox Code Playgroud)
在我的胶水文件中,我可以将数据表映射到对象Trade作为开箱即用的黄瓜解决方案:
@When("^trades with the following details are created:$")
public void trades_with_the_following_details_are_created(List<Trade> arg1) throws Throwable {
//do something with arg1
}
Run Code Online (Sandbox Code Playgroud)
我想要实现的目标:
通过执行以下操作来提高我的小黄瓜方案的可读性:
样品:
Scenario: Book an FX Trade
Given trades with the following details are …Run Code Online (Sandbox Code Playgroud)在 Cucumber 2 中,正则表达式表示为(.*)获取胶水代码的参数。Cucumber 3的表达式文档说“您可以使用正则表达式或 Cucumber 表达式”。但遗憾的是它没有提到语法。
在 Cucumber 3 和 4 中()表示可选文本,相当于(?:)在 Cucumber 2 中。
何时()为可选文本保留如何在 Cucumber 3 中定义正则表达式?作为{.*}?
cucumber-java ×10
cucumber ×7
cucumber-jvm ×6
java ×2
bdd ×1
gherkin ×1
java-7 ×1
java-8 ×1
kotlin ×1
maven ×1
spring-boot ×1