簡體   English   中英

沒有膠水文件的簡單黃瓜測試班通過

[英]Simple Cucumber Test Class Passes with no Glue File

這已經困擾了我半天了。 我似乎找不到問題。 基本上,我的工作區中有測試運行器,功能文件和步驟文件。 Java文件位於同一軟件包(即無軟件包)中。

下面是我的TestRunner.java

import org.junit.Test;
import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(features = "test/resources/features", tags = { "~@Ignore" })
public class TestRunner {

    @Test
    public void feature() {
    }
}

我的功能文件helloWorld.feature

Feature: Simple Test Feature

Scenario: Run Scenario ONE
GIVEN step one
WHEN step two
THEN step three

和我的步驟文件CucumberJava.java

import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;

public class CucumberJava {

    @Given("^step one$")
    public void step_one() {

        System.out.println("step one");
    }

    @When("step two")
    public void step_two() {
        System.out.println("step two");
    }

    @Then("^step three$")
    public void step_three() {
        System.out.println("step three");
    }
}

當我將TestRunner.java作為JUnit執行時,一切都通過了,但是在控制台中得到了以下內容:

0 Scenarios
0 Steps
0m0.000s

為什么? 實際上,當我從項目中刪除CucumberJava.java時,我得到的輸出完全相同。 我想念什么? 我也嘗試在TestRunner.java代碼中設置glue選項。 結果還是一樣。

非常感謝您的幫助。

要素(Given)等要素文件單詞在要素文件中為大寫。 他們需要像給定的那樣,即句子大小寫。

Feature: Simple Test Feature

Scenario: Run Scenario ONE
Given step one
When step two
Then step three

同樣,您可能需要在流道中的特征路徑后附加一個“ src”。 如果您使用的是Maven,則此features = "src/test/resources/features" 同樣也不需要在運行程序內部使用@Test annotation and method

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM