标签: cucumber-jvm

黄瓜场景大纲:在示例表中将空字符串""作为值传递

我有一个黄瓜场景大纲,其中示例表我想传递一个空字符串("")和换行符(\n \n \n)作为值.我想编辑一个文本字段,我正在删除字符串,并希望传入空字符串或换行符.我想发送此值并按Enter键.这看起来像这样.sendKeys(值+"\n").在示例表中,只是将值保留为空并传递\n \n \n不起作用.文本字段中的值不会更改.
这是Scenario大纲的样子:

Scenario Outline: Do not accept erroneous input as group conversation name (only spaces and break lines)
Given I Sign in using login <Login> and password <Password>
And I see Contact list with name <Name>
And I create group chat with <Contact1> and <Contact2>
When I open conversation with <Contact1>, <Contact2>
And I open Conversation info
And I set name <NewName> for conversation
Then I do not see conversation <NewName> in contact list
And I …
Run Code Online (Sandbox Code Playgroud)

string cucumber cucumber-jvm

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

cucumber-jvm从版本4升级到版本6时是否需要额外的上下文配置?

我正在使用 cucumber-jvm 在 Kotlin 中执行一些功能测试。

我有标准的空跑步者课程:

@RunWith(Cucumber::class)
@CucumberOptions(features=[foo],
    glue=[bar],
    plugin=[baz],
    strict=true,
    monochrome=true)
class Whatever
Run Code Online (Sandbox Code Playgroud)

实际步骤是在另一个类中使用 @ContextConfiguration springframework 注解定义的。该类还使用其他 spring 功能,如 @Autowire 或 @Qualifier

@ContextConfiguration(locations=["x/y/z/config.xml"])
class MyClass {
    ...
    @Before
    ...

    @Given("some feature file stuff")
    ...

    // etc
}
Run Code Online (Sandbox Code Playgroud)

这一切在 Cucumber 版本 4.2.0 中都可以正常工作,但是升级到版本 6.3.0 就会出现问题。更新导入以匹配新的 Cucumber 项目布局后,测试现在失败并出现以下错误:

io.cucumber.core.backend.CucumberBackendException:请使用一些上下文配置注释胶水类。

它提供了示例来说明其含义...

例如:

    @CucumberContextConfiguration
    @SpringBootTest(classes = TestConfig.class)
    public class CucumberSpringConfiguration {}
Run Code Online (Sandbox Code Playgroud)

或者:

    @CucumberContextConfiguration
    @ContextConfiguration( ... )
    public class CucumberSpringConfiguration {}
Run Code Online (Sandbox Code Playgroud)

看起来它告诉我我可以将 @CucumberContextConfiguration 添加到 MyClass 中。

但为什么?

我明白了 @CucumberContextConfiguration 的意思,这里解释得很好,但是为什么我现在需要版本 6,而版本 4 …

bdd cucumber cucumber-jvm cucumber-junit cucumber-java

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

是否可以使用Cucumber-jvm Scala避免可变状态?

随着黄瓜测试,功能表现为Given,When并且Then通常为三个独立的方法来实现.这些方法通常需要共享值,这似乎是可变变量的方法.

采用以下简单示例:

一项功能:

Given the digit 2
When it is multiplied by 3
Then the result is 6
Run Code Online (Sandbox Code Playgroud)

和黄瓜方法:

class CucumberRunner extends ScalaDsl with EN with ShouldMatchers {

  var digitUnderTest: Int = -1

  Given("""^the digit (\d)$""") { digit: Int =>
    digitUnderTest = digit
  }

  When("""^it is multiplied by 3$""") {
    digitUnderTest = digitUnderTest * 3
  }

  Then("""^the result is (\d)$""") { result: Int =>
    digitUnderTest should equal (result)
  }
}
Run Code Online (Sandbox Code Playgroud)

是否有任何方法,可能是内置于Scala测试或者Scala的Cucumber-jvm,这使我不能表达digitUnderTest为可变变量?

scala cucumber-jvm

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

黄瓜jvm CucumberException:[]没有找到任何功能

在我的黄瓜-jvm,Maven,junit Setup中我将testRunner文件作为

package com.lebara.testrunner;

import cucumber.junit.Cucumber;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@Cucumber.Options(

glue = {"com.lebara.stepdefs","com.lebara.framework.main", "com.lebara.testrunner"},
features = "C:/Users/sarthak.dayanand/Documents/WebRefreshTest/CukeAutomation/LebaraWebAutomationTest1/src/main/resources",
format = {"pretty", "html:target/cucumber-html-report", "json-pretty:target/cucumber-report.json"},
tags = {"@UserJourney"}

)
public class RunCukesTest {
}
Run Code Online (Sandbox Code Playgroud)

我在上面提到的目录中有我的功能文件.

如果我运行它,我会得到以下异常:

cucumber.runtime.CucumberException: No features found at [C:/Users/sarthak.dayanand/Documents/WebRefreshTest/CukeAutomation/LebaraWebAutomationTest1/src/main/resources/cucumber]...
Run Code Online (Sandbox Code Playgroud)

如果我删除了testrunner中的"features"选项,它会尝试在与我的testrunner.java相同的目录中查找功能文件

cucumber.runtime.CucumberException: No features found at [com/lebara/testrunner]
Run Code Online (Sandbox Code Playgroud)

如果我把功能文件放在那里,它就可以了.

我的问题是为什么我的功能文件没有被我以前的位置拾取,我认为这是黄瓜 - maven设置的默认文件结构.

我如何从那里取货?帮助赞赏.

cucumber cucumber-jvm cucumber-junit

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

整合Robolectric和黄瓜

我想结合Robolectric和Cucumber(JVM).

目前我有两个类ActivityStepdefs,其中定义了活动管理的两个步骤定义.

我的第二课是RoActivity例如,根据它的类名创建一个活动,以及将使用Robolectric的地方.

当我运行RoActivityTest使用RobolectricTestRunner这个类通过了测试,但是当我运行RunCukesTest(类运行特点JUnit测试)从代码中RoActivity不充当Robolectric,即部分RunCukesTest搜索我的项目特色,并与方法匹配它的内部ActivityStepdefs和最后这个类将调用一个方法RoActivity

是否可以使用junit和*runners进行测试?

我不确定,但也许可以使用junit规则做类似powermock的事情.

在那种情况下,我应该为哪一个定义规则?

*黄瓜和Robolectric

junit android cucumber robolectric cucumber-jvm

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

如何在Intellij Idea中指定步骤定义原型名称?

我写下我的黄瓜场景包括以下步骤:

And the frabjous bandersnatch whiffled "Callooh"
Run Code Online (Sandbox Code Playgroud)

输入alt-enter,选择Create Step Definition,它会产生:

@And("^the frabjous bandersnatch whiffled \"([^\"]*)\"$")
public void the_frabjous_bandersnatch_whiffled(String arg1) throws Throwable {
    // Express the Regexp above with the code you wish you had
    throw new PendingException();
}
Run Code Online (Sandbox Code Playgroud)

但是我们的编码标准要求使用camelCase方法,因此我必须手动更改the_frabjous_bandersnatch_whiffledtheFrabjousBandersnatchWhiffled.在这种情况下,是否有某个设置可以告诉Idea使用驼峰案而不是下划线?

此外,当它提供可以放置我的新stepdef的类时,我可以将它过滤到只有名称以"Steps"结尾的类吗?

coding-style intellij-idea content-assist cucumber-jvm

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

黄瓜junit runner java.lang.NoSuchMethodError:

试图实施黄瓜做一些自动化测试.jUnit测试.我创建了2个文件并编辑了maven项目附带的pom.xml来添加依赖项.内容如下所示.两个文件中的第一个是黄瓜.feature文件,它是简单语言的小黄瓜.另一个是CukesRunner.java

当我使用Project -> Run as ... -> Maven test它运行我的测试它按预期工作.

但是,当我使用Eclipse Eclipse JUnit GUI运行CukesRunner.java文件时,出现错误:

java.lang.NoSuchMethodError: org.junit.runner.Description.createSuiteDescription(Ljava/lang/String;Ljava/io/Serializable;[Ljava/lang/annotation/Annotation;)Lorg/junit/runner/Description;
    at cucumber.runtime.junit.FeatureRunner.getDescription(FeatureRunner.java:43)
    at cucumber.api.junit.Cucumber.describeChild(Cucumber.java:77)
    at cucumber.api.junit.Cucumber.describeChild(Cucumber.java:41)
    at org.junit.runners.ParentRunner.getDescription(ParentRunner.java:226)
    ... 
Run Code Online (Sandbox Code Playgroud)

pom.xml中:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.bdd</groupId>
  <artifactId>airportparking</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>airportparking</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>1.1.5</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>1.1.5</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.rubiconproject.oss</groupId>
            <artifactId>jchronic</artifactId>
            <version>0.2.6</version>
            <scope>test</scope>
        </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.8.2</version>
        <scope>test</scope>
    </dependency>
  </dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)


CukesRunner.java:

package com.bdd.airportparking;

import cucumber.api.junit.*;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@Cucumber.Options(
        format={"pretty", "html:target/cucumber"}, …
Run Code Online (Sandbox Code Playgroud)

java junit cucumber maven cucumber-jvm

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

Cucumber-jvm线程安全吗?

我想在多个线程中运行相同的Cucumber测试.更具体地说,我有一组功能,在一个线程中运行这些功能可以正常工作.我使用JSON格式化程序来记录每个步骤的运行时间.现在我想做负载测试.我更关心多线程环境中每个功能/步骤的运行时间.所以我创建了多个线程,每个线程都运行在同一个功能集上.每个线程都有自己的JSON报告.理论上这可能吗?

对于某些项目设置原因,我无法使用JUnit运行程序.所以我不得不采用CLI方式:

        long threadId = Thread.currentThread().getId();
        String jsonFilename = String.format("json:run/cucumber%d.json", threadId);

            String argv[] = new String[]{
                "--glue",
                "com.some.package",
                "--format",
                jsonFilename,
                "d:\\features"};

        // Do not call Main.run() directly. It has a System.exit() call at the end.             
        // Main.run(argv, Thread.currentThread().getContextClassLoader());

        // Copied the same code from Main.run(). 
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        RuntimeOptions runtimeOptions = new RuntimeOptions(new Env("cucumber-jvm"), argv);
        ResourceLoader resourceLoader = new MultiLoader(classLoader);
        ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader);
        Runtime runtime = new Runtime(resourceLoader, classFinder, classLoader, runtimeOptions);
        runtime.writeStepdefsJson();
        runtime.run();      
Run Code Online (Sandbox Code Playgroud)

我试图为每个Cucumber运行创建一个单独的线程.问题是,只有一个线程有一个有效的JSON报告.所有其他线程只创建空JSON文件.这是黄瓜的设计还是我错过了什么?

java multithreading gradle gpars cucumber-jvm

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

IntelliJ IDEA无法识别.feature文件

我在IntelliJ IDEA中安装了cuc-java和gherkin插件,但是当我创建.feature文件时,它不会被识别为特征文件.我确实重新启动了IntelliJ,并检查了插件设置窗口中是否启用了插件.IntelliJ中的功能文件

intellij-idea gherkin cucumber-jvm

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

是否有像Background这样的After关键字可用于运行黄瓜步骤

我知道背景关键字可用于在运行每个场景之前运行常见步骤。同样,是否有类似“After”关键字的内容可用于每个场景之后的公共步骤,而不是像 after hooks 这样的 java 代码中的逻辑步骤,我的意思是在小黄瓜步骤本身中。我需要像下面这样

Background
Given I use the API header information
  | Content-Type | application/json;v=3 |
And I connect to postgresql

Scenario Outline:
    And I get the "Request" payload from "5NB_CARD-A_Request" file for the scenario "CardA_Scenario1"
    And I store the input payload individual field details for database validation
    And I form a client with this resource url "/transaction"
    When I make a POST call and capture the response
    And I get the "response" payload from "5NB_CARD-A_Response" file …
Run Code Online (Sandbox Code Playgroud)

cucumber gherkin cucumber-jvm atdd

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