如何在scala中实现场景轮廓

时间:2015-02-26 04:43:46

标签: scala cucumber outline

我们目前正在使用Scala实施一些验收测试。

在cuke中,有一个场景概要的概念。

有没有人知道如何使用Scala中的FeatureSpec实现这一点?

提前致谢。

1 个答案:

答案 0 :(得分:0)

我认为场景大纲是一个黄瓜功能,我不确定你是否应该期望在现有的Scala测试库中找到奇偶校验。

话虽如此,我已经使用了黄瓜scala并在我的一些项目中使用了场景大纲,这里是我使用的依赖项(检查更新的版本,请不要假设这是结束 - 所有这样做的方式):

"com.novocode" % "junit-interface" % "0.11-RC1" % "test",
"info.cukes" % "cucumber-core" % "1.1.8" % "test",
"info.cukes" % "cucumber-junit" % "1.1.8" % "test",
"info.cukes" %% "cucumber-scala" % "1.1.8" % "test",
"org.mockito" % "mockito-core" % "1.9.5" % "test"

以下是我的跑步者的样子:

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

@RunWith(classOf[Cucumber])
class CucumberRunner {}

以下是加载大纲表的给定子句的示例:

Given("""^some data$""") { (t: DataTable) =>
  val input = t.asMaps(classOf[String], classOf[String])
  // use table data...
}

我把详细信息拿出来了,但那是处理这样的gerkin文件(存储在main/test/resources中的同一个包中):

Background:
  Given some data
    |  a |    b |     c |         d |
    |  1 |    a |   0.0 | s030d1h60 | 
    |  2 |    a |   1.0 | s030d1h60 | 
    |  3 |    a |   2.0 | s030d1h60 |     
  And some setup parameter "q"
  When the input is processed by the mock item

Scenario: The input can be validated
  Then the input will be marked as valid

Scenario: The input will be transformed
  Then the input will be trasformed into "abcdef"

我知道这并不是你想要的,但这对我来说是第一次尝试在Scala中做一些类似BDD的东西。希望它有所帮助。