是否可以有一个没有参数的步骤定义?

问题描述 投票:0回答:1

我有以下情况。

Feature: Spheres
  Scenario: A ray intersects a sphere at two points
    Given r ← ray(point(0, 0, -5), vector(0, 0, 1))
    And s ← sphere()
    When xs ← intersect(s, r)
    Then xs.count = 2
    And xs[0] = 4.0
    And xs[1] = 6.0

为了简单起见,我想先把步骤定义写成字面意思。

import io.cucumber.java8.En

class SphereStepDefinitions: En {
    private val epsilon: Double = 0.00001
    lateinit var s: Sphere
    lateinit var xs : List<Double>

    init {
        Given("s ← sphere\\()") {
            s = Sphere()
        }
    }
}

结果是:

The step "s ← sphere()" is undefined. You can implement it using the snippet(s) below:

Given("s ← sphere\\()", () -> {
    // Write code here that turns the phrase above into concrete actions
    throw new io.cucumber.java8.PendingException();
});

这和我已经指定的步骤字符串完全一样 :(

我在项目中已经有很多工作步骤了,但我想这是我第一次尝试没有任何参数的步骤......难道这就是不工作的东西?

我使用cucumber-jvm 5.7.0(也试过5.6.0和6.0.0-RC2)和Kotlin 1.3.72,在Java 11上。

kotlin cucumber cucumber-jvm
1个回答
1
投票

你现在用的是黄瓜表达式。看起来像 黄瓜没有生成正确的黄瓜表达式代码段。.

你可以使用常规的表达方式(通过使用 ^$):

^s ← sphere\\(\\)$

或者使用:

s ← sphere() 来绕过这个错误。我推荐前者而不是后者。

© www.soinside.com 2019 - 2024. All rights reserved.