黄瓜 - 功能文件中的内容帮助不起作用

Cucumber - Content Assistance in Feature file not working

所以,我一直很难通过 Cucumber/Scala 集成来降低依赖性。我终于有了一个简单的步骤定义 运行ning,但是当我按下 control + space 栏时,步骤定义列表没有显示在我的功能文件中。但是,当我 运行 功能文件时,它 运行 成功了。

测试运行程序

package CucumberTest

import cucumber.api.CucumberOptions
import cucumber.api.junit.Cucumber
import org.junit.runner.RunWith

@RunWith(classOf[Cucumber])
@CucumberOptions(
        features = Array("Feature")
        ,glue= Array("stepDefinition")
        ,plugin = Array ("pretty", "html:target/cucumber/html")
        )
class TestRunner {
  def main(args: Array[String]): Unit = {
    println("Hi")
  }
}

步骤定义文件

包步骤定义

import cucumber.api.scala.{ ScalaDsl, EN }


class Test_Steps extends ScalaDsl with EN{
  Given("""^this pre condition$""") { () =>
    println("YOOOOOOOOO!!!")
  }
  When("""^I do this$""") { () =>
    //// Write code here that turns the phrase above into concrete actions
  }
  Then("""^I can verify that$""") { () =>
    //// Write code here that turns the phrase above into concrete actions
  }
  Then("""^I can also verify that$""") { () =>
    //// Write code here that turns the phrase above into concrete actions
}

这就是我的功能的样子。 "this pre condition" 以黄色突出显示,表示特征文件未找到胶水代码。

当我将鼠标悬停在 Given 语句上时,我收到此消息

Step 'this pre condition' does not have a matching glue code

但是当我 运行 它时,我得到这个作为输出。

Scala 控制台输出

因为 YOOOOOOOOO!!!打印在控制台上,它看到我的胶水代码并且 运行ning 成功,但我没有得到步骤定义列表并且短语 "this pre condition" 以黄色突出显示。

有人知道问题出在哪里吗?

这里有一些与cucumber/scala

相关的依赖

    <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-java -->
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>1.2.4</version>
    </dependency>

    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-scala_2.11</artifactId>
        <version>1.2.4</version>
    </dependency>

    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>1.2.4</version>
    </dependency>
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>gherkin</artifactId>
        <version>2.12.2</version>
    </dependency>
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-core</artifactId>
        <version>1.2.4</version>
    </dependency>
   <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-nop</artifactId>
        <version>1.7.12</version>
    </dependency>
    <dependency>
      <groupId>org.scala-lang</groupId>
      <artifactId>scala-library</artifactId>
      <version>2.11.8</version>
    </dependency>

所以我认为问题是依赖性不匹配以及未将 Junit 添加到我的项目路径的组合。

这就是我的 Test_Steps class 现在的样子。我从 Cucumber java api 导入了库。

package stepDefinition

//import org.slf4j.LoggerFactory
import cucumber.api.java.en.Given;
import cucumber.api.scala._
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import cucumber.api.java8._
import cucumber.api.scala.{ ScalaDsl, EN }
import cucumber.runtime.java.StepDefAnnotation

@StepDefAnnotation
class Test_Steps extends ScalaDsl with EN {

  //this works
  @Given("""^this pre condition$""")
  def this_pre_condition() = {
    println("Hello")
  }

  @When("""^blah condition$""")
  def when_condition() = {
    println("In the when statement -- ")
  }

}

我的功能文件的内容辅助功能现在可以使用了。

联合输出

控制台输出