这里拿官网的示例 is_it_friday_yet.feature 来跑~并计算Coverage~~
代码
is_it_friday_yet.feature
Feature: Is it Friday yet?
Everybody wants to know when it's Friday
Scenario: Sunday isn't Friday
Given today is Sunday
When I ask whether it's Friday yet
Then I should be told "Nope"
StepDefinitions.java
public class StepDefinitions {
@Given("today is Sunday")
public void today_is_sunday() {
System.out.println("today_is_sunday");
// Write code here that turns the phrase above into concrete actions
// throw new io.cucumber.java.PendingException();
}
@When("I ask whether it's Friday yet")
public void i_ask_whether_it_s_friday_yet() {
System.out.println("i_ask_whether_it_s_friday_yet");
// Write code here that turns the phrase above into concrete actions
// throw new io.cucumber.java.PendingException();
}
@Then("I should be told {string}")
public void i_should_be_told(String string) {
System.out.println("i_should_be_told");
// Write code here that turns the phrase above into concrete actions
// throw new io.cucumber.java.PendingException();
}
}
执行结果
点击Scenario左侧的▶️执行该Scenario,出现下图则执行成功
计算该场景的Coverage
会发现…跑了个寂寞,啥都木有
如何解决Coverage都是0的问题
1. 配置Configurations
2. 将逻辑代码所在的包添加到include中
就是这个样纸:
3. 记得勾选Enable coverage in test folder(这里绊了我好久= =)
4. 再重新执行Run xxx with Coverage
铛铛铛~~撒花🎉🎉🎉~~~
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/135440.html