2017-03-07 97 views
0

我正在學習黃瓜日蝕中的BDD。我已經下載了所有的jar文件,但仍然是eclipse,它說它找不到其他文本的定義。黃瓜黃瓜問題 - 沒有找到匹配的膠水代碼

Feature: Login 

Scenario: Successful Login with valid Credentials 
    Given user is on Homepage 
    When user enters Username and Password 
    Then He can visit the practice page 

在上面的代碼,它找不到膠水代碼如下文字:

  1. 用戶在首頁
  2. 用戶輸入用戶名和密碼
  3. 他可以參觀實踐頁面
+0

請分享您的文件格式和跑步者等級。您遇到的問題可能有很多不同的原因,我們沒有足夠的信息來幫助您。 –

回答

0

你能粘貼你得到的確切錯誤嗎?

你有step_definitions文件,你已經在features文件夾裏面編寫了小黃瓜步驟的代碼嗎?

0

檢查這些選項

選項1: 確保您運行的代碼,黃瓜功能並用黃瓜插件

Cucumber Plugin

在你的情況幫助產生的骨架,黃瓜將打印像這樣

//Print start 
@Given("^user is on Homepage$") 
public void user_is_on_Homepage() throws Throwable { 
    // Write code here that turns the phrase above into concrete actions 
    throw new PendingException(); 
} 

@When("^user enters Username and Password$") 
public void user_enters_Username_and_Password() throws Throwable { 
    // Write code here that turns the phrase above into concrete actions 
    throw new PendingException(); 
} 

@Then("^He can visit the practice page$") 
public void he_can_visit_the_practice_page() throws Throwable { 
    // Write code here that turns the phrase above into concrete actions 
    throw new PendingException(); 
} 
//Print End 

創建程序包features.stepDefinitions然後creat具有上述生成的骨架的e類文件「ABC.java」。請繼續選項2

選項2

如果下面的類是亞軍,我們需要具有以下特徵:文件夾的膠水。通常它會在資源文件夾

package test.runner 
import org.junit.runner.RunWith; 
import cucumber.api.CucumberOptions; 

@CucumberOptions(
      features="src/test/resources/features/featureFileFolder", 
      glue = { "features.stepDefinitions"}, 
      tags={"@UI"}, 
      monochrome=true) 
    public class Runner{ 

    } 

最後執行亞軍文件作爲JUnit測試

注:

標籤UI是我們將使用鏈接的場景和註釋。

在這種情況下,功能文件將寫爲。

@UI

情景:成功登錄使用有效憑據

鑑於用戶在首頁

當用戶輸入用戶名和密碼

那麼他就可以訪問該頁面的做法

希望這可以幫助!