gpt4 book ai didi

scala - 你如何使用 Scala 2.11 和 sbt 0.13 运行 cucumber ?

转载 作者:行者123 更新时间:2023-12-04 06:16:59 24 4
gpt4 key购买 nike

有没有人有一个带有 sbt 0.13 和 Scala 2.11 的 cucumber 项目的例子?

  • 我需要cucumber-scala_2.11吗?和 sbt-cucumber-plugin" % "0.8.0" (那个插件是最新的)?
  • 插件现在去哪里了?
  • 哪里有.feature文件去?
  • cucumber 测试去哪里?
  • 如何从 sbt 运行测试?
  • (可选)如何从 IntellJ (15) 运行测试?
  • 最佳答案

    好的,我想出了一个带有以下警告的解决方案:我没有使用 sbt。
    主意
    我们将首先编写 cucumber 特性和步骤。然后我们将编写一个“Runner”类,该类将由 JUnit runner 运行(它将忽略 cucumber 的存在)
    程序
    步骤 1 .只依赖一件事来编写 cucumber 功能和步骤!

    libraryDependencies += "info.cukes" % "cucumber-scala_2.11" % "1.2.4"
    步骤 2 :现在我们依赖于 junit(用于编写我们的测试运行程序)和 Cucumber-junit 连接库,这将允许我们告诉 JUni 运行我们的 Cucumber 测试:
    libraryDependencies += "info.cukes" % "cucumber-junit" % "1.2.4"
    libraryDependencies += "junit" % "junit" % "4.12"
    步骤 3 :编写功能和步骤定义(根据我的经验,它们应该放在测试中的同一文件夹中):
    # My.feature
    Feature: blah blah
    ....

    // MySteps.scala
    ...
    第 4 步 :编写我们的测试运行程序:
    import cucumber.api.junit.Cucumber
    import org.junit.runner.RunWith
    @RunWith(classOf[Cucumber])
    class RunTests extends {
    }
    步骤 5 :(可选)与 IntelliJ 集成
    a) 在 IntelliJ 中启用 JUnit。这将允许我们通过运行我们的 junit runner 来运行我们的 cucumber 测试。美丽的!
  • 文件
  • 设置...
  • 插件
  • 搜索“JUnit”并确保它已启用
    现在我们可以通过简单地右键单击 .feature 文件并选择运行来运行我们的 cucumber 测试!

  • b) 为 Scala IntelliJ 插件启用 Cucumber。 (确保启用了 Scala 插件)。这使 IntelliJ 能够确定如何将特征文件与 Scala 文件相关联。如果没有这个,您的功能文件将始终以黄色突出显示并显示错误 undefined step reference :
  • 文件
  • 设置...
  • 插件
  • 浏览存储库...
  • 搜索“Cucumber for Scala”
  • 安装 Cucumber for Scala插入
  • 重新启动 IntelliJ。
    现在您的功能文件将正确突出显示!

  • 有用的资源
  • cucumber 的 Java 教程,这让我找到了这个解决方案:https://c0deattack.wordpress.com/2012/03/28/cucumber-jvm-with-cucumber-java-cucumber-junit-example/
  • 人 super 乐于助人的 cucumber 聊天室:https://gitter.im/cucumber/chat
  • 目录结构(请注意,在 Scala 中,我们似乎需要将功能文件和步骤文件放在同一个文件夹中:但是单个运行者的想法很有趣):http://www.hascode.com/2014/12/bdd-testing-with-cucumber-java-and-junit/#Directory_Structure
  • 关于scala - 你如何使用 Scala 2.11 和 sbt 0.13 运行 cucumber ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33020504/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com