Cucumber Test的Coverage都是0怎么辦...

這里拿官網(wǎng)的示例 is_it_friday_yet.feature 來跑~并計算Coverage~~

代碼

is_it_friday_yet.feature

image.png
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

image.png
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();
    }
}
 

執(zhí)行結果

點擊Scenario左側的??執(zhí)行該Scenario,出現(xiàn)下圖則執(zhí)行成功


image.png

計算該場景的Coverage

image.png

會發(fā)現(xiàn)...跑了個寂寞,啥都木有


image.png

如何解決Coverage都是0的問題

  1. 配置Configurations
image.png

2. 將邏輯代碼所在的包添加到include中

image.png

就是這個樣紙:

image.png

3. 記得勾選Enable coverage in test folder(這里絆了我好久= =)


image.png

4. 再重新執(zhí)行Run xxx with Coverage

image.png

鐺鐺鐺~~撒花??????~~~

?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容