And*_*yuk 10
好吧,我想出了一个解决方案,但有以下警告:我没有使用sbt.
我们将首先编写黄瓜功能和步骤.然后我们将编写一个"Runner"类,它将由JUnit运行程序运行(它将忽略黄瓜的存在)
第1步.只写一件事就是写黄瓜的功能和步骤!
libraryDependencies += "info.cukes" % "cucumber-scala_2.11" % "1.2.4"
Run Code Online (Sandbox Code Playgroud)
第2步:现在我们依赖junit(用于编写我们的测试运行器)和cucumber-junit连接库,这将允许我们告诉 JUni运行我们的黄瓜测试:
libraryDependencies += "info.cukes" % "cucumber-junit" % "1.2.4"
libraryDependencies += "junit" % "junit" % "4.12"
Run Code Online (Sandbox Code Playgroud)
第3步:编写功能和步骤定义(根据我的经验,它们应放在测试中的同一文件夹中):
# My.feature
Feature: blah blah
....
// MySteps.scala
...
Run Code Online (Sandbox Code Playgroud)
第4步:写我们的测试亚军:
import cucumber.api.junit.Cucumber
import org.junit.runner.RunWith
@RunWith(classOf[Cucumber])
class RunTests extends {
}
Run Code Online (Sandbox Code Playgroud)
第5步 :(可选)与IntelliJ集成
a)在IntelliJ中启用JUnit.这将允许我们通过运行我们的junit runner 来运行我们的黄瓜测试.美丽!
搜索"JUnit"并确保它已启用
现在我们只需右键单击.feature文件并选择Run 即可运行我们的黄瓜测试!
b)为Scala IntelliJ插件启用Cucumber.(确保启用了Scala插件).这使IntelliJ能够确定如何将要素文件与scala文件相关联.如果没有这个,您的要素文件将始终以黄色突出显示,并显示错误undefined step reference
:
Cucumber for Scala
插件重启IntelliJ.
现在您的功能文件将正确突出显示!
归档时间: |
|
查看次数: |
3634 次 |
最近记录: |