标签: cucumber-junit

用Cucumber截取屏幕截图

我只是学习如何使用黄瓜.你能告诉我如何完成这段代码吗?

您可以使用以下代码段实现未定义步骤的步骤定义:

Then /^I take a screenshot$/ do
    pending # express the regexp above with the code you wish you had
end
Run Code Online (Sandbox Code Playgroud)

cucumber cucumber-jvm cucumber-junit cucumber-cpp

1
推荐指数
1
解决办法
2万
查看次数

如何解决已弃用的@CucumberOptions?

在下面的代码中,我使用了@ cucumber.options。但是它已被弃用。

所以我正在尝试使用@cucumberoptions,它需要导入“ cucumber.api.CucumberOptions”。但是,当我签入我的Maven依赖项时,cucumber.api不包含黄瓜选项。我正在为导入“导入cuming.api.CucumberOptions;”添加一条红线。

我的目的是创建一个好的报告并设定其路径。

我可以找到一个相关的问题- 如何解决@CucumberOptions中的format选项弃用?在这里,但找不到我正在寻找的答案。如果您能找到解决方案,我将不胜感激。

我的代码如下:

package featurefiles;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.*;
@RunWith(Cucumber.class)
@CucumberOptions(strict = false, features = "features", format = { "pretty",
    "html:target/site/cucumber-pretty",
    "json:target/cucumber.json" }, tags = { "~@ignore" })
public class CucumberTestRunner {
}
Run Code Online (Sandbox Code Playgroud)

cucumber cucumber-jvm cucumber-junit

1
推荐指数
2
解决办法
5266
查看次数

从黄瓜Java中的场景大纲示例表中解析整数列表

我必须使用Java黄瓜来编写BDD测试,我想从示例表的每一行中解析一个整数列表,然后使用最新版本的Cucumber(4.2.6)将此列表传递给我的step方法。因此,我在功能文件中获得了以下步骤定义:

Scenario Outline: Some scenarion
    Given a list of integer: <integer_list> 

    Examples:
      | integer_list   |
      | 2, 3, 5, 6     | 
      | 3, 12, 45, 5, 6| 
Run Code Online (Sandbox Code Playgroud)

我的代码中需要这样的内容:

   @Given("a list of integer: (\\d+.)")
    public void storeIntegerList(List<Integer> integers) {
     System.out.println(integers.size());
    }
Run Code Online (Sandbox Code Playgroud)

不幸的是,我找不到一种将这些值解析为列表的方法。要么找不到step方法(我尝试过很多不同的正则表达式),要么抛出异常,通知我我的数字无法转换为列表。

解决方法是将列表解析为字符串,然后将其拆分。但是,我无法想象在2019年没有更好的方法可以做到这一点。

解决方法:

Scenario Outline: Some scenarion
    Given a list of integer: "<integer_list>" 

    Examples:
      | integer_list   |
      | 2, 3, 5, 6     | 
      | 3, 12, 45, 5, 6| 


@Given("a list of integer: {string}")
    public void storeIntegerList(String integers) {
        List<String> …
Run Code Online (Sandbox Code Playgroud)

java cucumber cucumber-jvm cucumber-junit cucumber-java

1
推荐指数
1
解决办法
719
查看次数

在Cucumber-JUnit中,有没有办法控制功能报告的顺序?

我运行具有两个功能的基本黄瓜(JVM)的测试,称为"基本数学"和"高等数学"(在文件中basic_math.featureadvanced_math.feature分别).

但是,当HTML报告生成时,"高级数学"会在"基础数学"之前显示,而我希望"基础数学"出现 "高级数学" 之前.这并非易事,因为如果我能够更加逻辑地组织输出,那么我们的业务分析师和QA部门将更容易获得报告,并且我将能够获得更多的牵引力.

我知道我可以尝试使用Maven插件进行某种XSLT后期处理,但我正在寻找使用注释在代码中定义它的方法.有这样的方式吗?Cucumber.@Options.features实际上定义.feature文件位置,Cucumber.@Options.name用于确定运行哪些功能的rexexps.

junit cucumber-jvm cucumber-junit

0
推荐指数
1
解决办法
3363
查看次数

如何使用 @tags 在 Cucumber 框架中运行 testrunner 类文件中的多个标签?

@RunWith(Cucumber.class)
@CucumberOptions( plugin = {"pretty","html:target/html/automation"},
                features = {"resource/***.feature"},
                glue={},
                tags={"@login","@Products"}
        )
Run Code Online (Sandbox Code Playgroud)

这是我的功能文件

@登录

功能:登录应用程序

场景:这是验证应用程序是否已成功登录给定导航到 Panasonic 应用程序然后验证应用程序的标题然后注销应用程序

@产品

功能:登录应用程序

背景:用户应该导航到应用程序的主页

给定用户使用有效凭据登录主页

单击主页上的目录链接时

场景:验证产品页面是否可以创建十个以上产品

并检查目录的子菜单是否显示在标题中

并检查我的产品目录表

java selenium cucumber-junit selenium-webdriver cucumber-java

0
推荐指数
1
解决办法
5万
查看次数

Cucumber-JUnit,有没有办法控制运行@before和@after标签的顺序

我有两个@after标签,@ close-browser和@ screenshot.So,现在当我将两个标签用于特征文件时,它首先执行@ close-browser,并且在执行@screenshot方法后失败.有没有办法告诉黄瓜先在方法之后运行@screenshot?

java junit cucumber cucumber-jvm cucumber-junit

0
推荐指数
1
解决办法
2206
查看次数

Cucumber:java.lang.IllegalArgumentException:不是文件或目录:G:\ Codebase\MavenCucumber\ - plugin

每当我尝试在eclipse中运行我的功能文件时使用Maven我收到以下错误:

线程"main"中的异常java.lang.IllegalArgumentException:不是文件或目录:G:\ Codebase\MavenCucumber - 在cucumber.runtime的cucumber.runtime.io.FileResourceIterator $ FileIterator.(FileResourceIterator.java:54)插件. io.FileResourceIterator.(FileResourceIterator.java:20)位于cucumber.runtime.mun上的cucumber.runtime.io.FileResourceIterable.iterator(FileResourceIterable.java:19),来自cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:38).在cucumber.api.cli.Mun.run(Main.java:20)的cucumber.runtime.Runtime.run(Runtime.java:92)运行的RuntimeOptions.cucumberFeatures(RuntimeOptions.java:117),来自cucumber.api.cli.Main .主要(Main.java:12)

在此输入图像描述

上面的图片是我项目的结构,而功能文件包含以下代码 -

@tag
Feature: Proof of Concept

  @tag1
  Scenario: This is my first test Scenerio
    Given This is my first step
    When This is my second step
    Then This is my third step
Run Code Online (Sandbox Code Playgroud)

java maven cucumber-junit

0
推荐指数
1
解决办法
1万
查看次数

为什么我的黄瓜测试用例被跳过?

我正在使用带有spring-restWeb服务的Cucumber测试框架。我正在使用标准的黄瓜JUnit框架和Gradle构建工具。

这是依赖项

testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('info.cukes:cucumber-java:1.2.4')
testCompile('info.cukes:cucumber-junit:1.2.4')
testCompile ("info.cukes:cucumber-spring:1.2.4")
testCompile('org.springframework.security:spring-security-test')
Run Code Online (Sandbox Code Playgroud)

这是我的功能文件,功能文件的位置是 src/main/resources/feature/addition.feature

Feature: Testing a REST API
   Users should be able to add two numbers

Scenario: number addition service
 When baseUri is /messages/add
   Then result should be 3
Run Code Online (Sandbox Code Playgroud)

这是我的步骤定义代码。它驻留在test/java/somepackage/

public class StepDefinition {

    @When("^baseUri is (.*)$")
    public void baseUri(String uri) {

    }

    @Then("result should be (\\d+)")
    public void checkResult(int result){
      Assert.assertEquals(result, this.result);
    }
}
Run Code Online (Sandbox Code Playgroud)

我的测试运行器类是,测试运行器和StepDefinition都在同一包中 /test/java

@RunWith(Cucumber.class)
@CucumberOptions(features = "classpath:feature/", glue = {"com.example.restdemo.web.StepDefinition"}, format = {"pretty", "html:target/cucumber"})
public class …
Run Code Online (Sandbox Code Playgroud)

java junit spring cucumber cucumber-junit

0
推荐指数
1
解决办法
5521
查看次数

运行黄瓜测试时,为什么会跳过它们?

我对 Cucumber 测试和 Spring boot 都很陌生。我在 pom.xml 文件 `
CucumberIntergration.test中添加了 cucumber-java 和 cucumber-junit

@RunWith(Cucumber.class)
@CucumberOptions(features = "src/test/resources/features/", plugin = 
{"pretty", "html:target/cucumber"},dryRun = true,glue = 
{"com.villvay.gudppl.ws"})
Run Code Online (Sandbox Code Playgroud)

这是 Version.feature 文件,用于 Api 版本验证的功能文件。

Feature: the version can be retrieved
 Scenario: client makes call to GET /version
 Given the client makes the api call for verification
 When  the client retrieve the response
 Then  the client verify the response
Run Code Online (Sandbox Code Playgroud)

这是 VersionStepDefinitions.java 文件的一部分,我在其中找到了我的测试。

  @Given("^the client makes the api call for verification")
  public void wants(){
    LOG.info("Client wants …
Run Code Online (Sandbox Code Playgroud)

java maven cucumber-junit spring-boot cucumber-java

0
推荐指数
1
解决办法
3659
查看次数