【发布时间】:2015-09-07 08:33:53
【问题描述】:
我的黄瓜测试有问题。它运行@Before 方法
所有的胶水类。
例如。此功能文件在MainStepDef.class 中有一个粘合代码。
#language: en
@run
Feature: Testing a feature
Test before method
Background:
Given stuff is created
Scenario: The test
When i do stuff
Then stuff will be done
MainStepDef:
public class MainStepDef {
@Before
public void setup() {
System.out.println("This is OK!");
}
@Given("^stuff is created$")
public void stuff_is_created() throws Throwable {
}
@When("^i do stuff$")
public void i_do_stuff() throws Throwable {
}
@Then("^stuff will be done$")
public void stuff_will_be_done() throws Throwable {
}
}
我有一个额外的胶水文件名为:OtherStep.class
public class OtherStepDef {
@Before
public void setup() {
throw new RuntimeException("No! Bad code! BAD CODE!");
}
@Given("^some other stuff is also created$")
public void some_other_stuff_is_also_created() throws Throwable {
}
}
最后我有我的跑步者课。
@RunWith(Cucumber.class)
@CucumberOptions(strict = true, tags = {"@run", "~@ignore" },
format = {"html:target/systemtest", "pretty" }, features = "classpath:features/",
glue = {"com.sorkmos.stepdef" }, monochrome = true)
public class RunFeatures {
}
当我运行它时,我从 OtherStepDef 设置方法中得到运行时异常。
为什么会这样?它不应该只执行功能所需的粘合吗?
【问题讨论】:
标签: java junit cucumber-jvm