我一直在拼命试图解决一个黄瓜Junit步骤执行。黄瓜JUNIT步骤执行忽略
我只是跟着限定特征,测试和步骤如下的一个简单的例子:
Feature: Campaign Budget Calculation
Scenario: Valid Input Parameters
Given campaign budget as 100 and campaign amount spent as 120
When the campaign budget is less than campaign amount spent
Then throw an Error
测试:
@RunWith(Cucumber.class)
@Cucumber.Options(glue = { "com.reachlocal.opt.dbas" })
public class CampaignTest {
}
步骤:
public class CampaignTestStepDefinitions {
private Campaign campaign;
@Given("^a campaign with (\\d+) of budget and (\\d+) of amount spent$")
public void createCampaign(int arg1, int arg2) throws Throwable{
CurrencyUnit usd = CurrencyUnit.of("USD");
campaign = new Campaign();
campaign.setCampaignBudget(Money.of(usd, arg1));
campaign.setCampaignAmountSpent(Money.of(usd, arg2));
}
@When("^compare the budget and the amount spent$")
public void checkCampaignBudget() throws Throwable{
if (campaign.getCampaignBudget().isLessThan(campaign.getCampaignAmountSpent())) {
campaign.setExceptionFlag(new Boolean(false));
}
}
@Then("^check campaign exception$")
public void checkCampaignException() throws Throwable{
if (campaign.getExceptionFlag()) {
assertEquals(new Boolean(true), campaign.getExceptionFlag());
}
}
}
当运行junit,跳过这些步骤,结果显示它们全部被忽略。我以前没有使用过胶水,但没有帮助。 不知道为什么。来自Internet的简单示例代码(如添加2个数字)工作正常。 我在使用STS的Maven/Spring项目中运行它。