2014-10-03 96 views
0

我嘗試通過命令行執行我的maven cucumber-JVM項目時遇到困難,該項目在eclipse環境中工作正常,但是我犯了一個非常愚蠢的錯誤。有人能指出什麼莫非,我會附上相關錯誤的圖像,通過命令行的黃瓜maven

<mainClass>cucumber.api.cli.Main</mainClass> 
      <includePluginDependencies>true</includePluginDependencies> 
      <arguments> 
       <argument>--format</argument> 
       <argument>junit:target/cucumber-junit-report/allcukes.xml</argument> 
       <argument>--format</argument> 
       <argument>pretty</argument> 
       <argument>--format</argument> 
       <argument>html:target/cucumber-html-report</argument> 
       <argument>--tags</argument> 
       <argument>@kings</argument> 
       <argument>--glue</argument> 
       <argument>com/Science_Ware/Bilal/KingsPostLogin/</argument> 
       <argument>src/test/resources</argument> 

      </arguments> 

以上就是我的pom.xml文件和我的類目錄,在這裏我感覺錯誤可能是。我的功能文件在src/test/resources中,我的步驟類路徑是com.Science_Ware.Bilal.KingsPostLogin,我的Classname也是KingsPostLogin。

C:\Users\********\My Documents\EclipseWork\Science-Ware>mvn exec:java 
[INFO] Scanning for projects... 
[INFO] 
[INFO] ------------------------------------------------------------------------ 
[INFO] Building Science-Ware 0.0.1-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- exec-maven-plugin:1.3.2:java (default-cli) @ Science-Ware --- 
[WARNING] Warning: killAfter is now deprecated. Do you need it ? Please comment 
on MEXEC-6. 
Feature: Login and clicking on Content Containers 

    In Order to Work in Microsoft 
    I want to log in 
    and verify content containers 

    @kings 
    Scenario Outline: Loggin in Science Warehouse ←[90m# com/Science_Ware/Bilal/Ki 
ngsPostLogin/kingspostlogin.feature:7←[0m 
    ←[36mGiven ←[0m←[36mI am logged into system on "Mozilla"←[0m 
    ←[36mAnd ←[0m←[36mI click on "<Content_Container>"←[0m 
    ←[36mThen ←[0m←[36mProcess should be "<Expected_Result>"←[0m 

    Examples: 

    @kings 
    Scenario Outline: Loggin in Science Warehouse ←[90m# com/Science_Ware/Bilal/Ki 
ngsPostLogin/kingspostlogin.feature:15←[0m 
    ←[33mGiven ←[0m←[33mI am logged into system on "Mozilla"←[0m 
    ←[33mAnd ←[0m←[33mI click on "OrderCentre"←[0m 
    ←[33mThen ←[0m←[33mProcess should be "OrderCentreTitle"←[0m 

    @kings 
    Scenario Outline: Loggin in Science Warehouse ←[90m# com/Science_Ware/Bilal/ 
KingsPostLogin/kingspostlogin.feature:16←[0m 
    ←[33mGiven ←[0m←[33mI am logged into system on "Mozilla"←[0m 
    ←[33mAnd ←[0m←[33mI click on "AggregateOrders"←[0m 
    ←[33mThen ←[0m←[33mProcess should be "AggregateOrdersTitle"←[0m 

    @kings 
    Scenario Outline: Loggin in Science Warehouse ←[90m# com/Science_Ware/Bilal/ 
KingsPostLogin/kingspostlogin.feature:17←[0m 
    ←[33mGiven ←[0m←[33mI am logged into system on "Mozilla"←[0m 
    ←[33mAnd ←[0m←[33mI click on "FreeFormatOrder"←[0m 
    ←[33mThen ←[0m←[33mProcess should be "FreeFormatOrderTitle"←[0m 

    @kings 
    Scenario Outline: Loggin in Science Warehouse ←[90m# com/Science_Ware/Bilal/Ki 
ngsPostLogin/kingspostlogin.feature:18←[0m 
    ←[33mGiven ←[0m←[33mI am logged into system on "Mozilla"←[0m 
    ←[33mAnd ←[0m←[33mI click on "GetAQuote"←[0m 
    ←[33mThen ←[0m←[33mProcess should be "GetAQuoteTitle"←[0m 

    @kings 
    Scenario Outline: Loggin in Science Warehouse  ←[90m# com/Science_Ware/Bila 
l/KingsPostLogin/kingspostlogin.feature:19←[0m 
    ←[33mGiven ←[0m←[33mI am logged into system on "Mozilla"←[0m 
    ←[33mAnd ←[0m←[33mI click on "ComputerEquipment"←[0m 
    ←[33mThen ←[0m←[33mProcess should be "ComputerEquipmentTitle"←[0m 

    @kings 
    Scenario Outline: Loggin in Science Warehouse ←[90m# com/Science_Ware/Bilal/Ki 
ngsPostLogin/kingspostlogin.feature:20←[0m 
    ←[33mGiven ←[0m←[33mI am logged into system on "Mozilla"←[0m 
    ←[33mAnd ←[0m←[33mI click on "Oligos"←[0m 
    ←[33mThen ←[0m←[33mProcess should be "OligosTitle"←[0m 

    @kings 
    Scenario Outline: Loggin in Science Warehouse ←[90m# com/Science_Ware/Bilal/Ki 
ngsPostLogin/kingspostlogin.feature:21←[0m 
    ←[33mGiven ←[0m←[33mI am logged into system on "Mozilla"←[0m 
    ←[33mAnd ←[0m←[33mI click on "eTracker"←[0m 
    ←[33mThen ←[0m←[33mProcess should be "eTrackerTitle"←[0m 

    @kings 
    Scenario Outline: Loggin in Science Warehouse ←[90m# com/Science_Ware/Bilal 
/KingsPostLogin/kingspostlogin.feature:22←[0m 
    ←[33mGiven ←[0m←[33mI am logged into system on "Mozilla"←[0m 
    ←[33mAnd ←[0m←[33mI click on "BrowseCategories"←[0m 
    ←[33mThen ←[0m←[33mProcess should be "BrowseCategoriesTitle"←[0m 

    @kings 
    Scenario Outline: Loggin in Science Warehouse ←[90m# com/Science_Ware/Bilal/ 
KingsPostLogin/kingspostlogin.feature:23←[0m 
    ←[33mGiven ←[0m←[33mI am logged into system on "Mozilla"←[0m 
    ←[33mAnd ←[0m←[33mI click on "BrowseSuppliers"←[0m 
    ←[33mThen ←[0m←[33mProcess should be "BrowseSuppliersTitle"←[0m 

9 Scenarios (←[33m9 undefined←[0m) 
27 Steps (←[33m27 undefined←[0m) 
0m0.000s 


You can implement missing steps with the snippets below: 

@Given("^I am logged into system on \"(.*?)\"$") 
public void i_am_logged_into_system_on(String arg1) throws Throwable { 
    // Write code here that turns the phrase above into concrete actions 
    throw new PendingException(); 
} 

@Given("^I click on \"(.*?)\"$") 
public void i_click_on(String arg1) throws Throwable { 
    // Write code here that turns the phrase above into concrete actions 
    throw new PendingException(); 
} 

@Then("^Process should be \"(.*?)\"$") 
public void process_should_be(String arg1) throws Throwable { 
    // Write code here that turns the phrase above into concrete actions 
    throw new PendingException(); 
} 

上面是我的命令行執行沒有調用我的任何步驟方法。他們只運行沒有任何輸出。我正在使用mvn exec:java命令來執行。

+0

因此,您在步驟文件中缺少一些方法。錯誤告訴你這個:) – Reimeus 2014-10-03 10:36:54

+0

我已經有了提供這些步驟的類文件,第二個給定應該是@And。此外,我剛剛跑過我的亞軍班,它工作正常,只是通過命令提示問題 – user1584614 2014-10-03 10:41:47

+0

步驟文件實際上位於'com/Science_Ware/Bilal/KingsPostLogin /'?因爲看起來Cucumber找不到它們。 – Marit 2018-01-04 19:21:11

回答

1

我覺得有兩個問題。首先,你可能不應該從命令行運行黃瓜。要運行它們,只需添加一個單元測試看起來應該像這樣:

import cucumber.api.junit.Cucumber; 
import org.junit.runner.RunWith; 

@RunWith(Cucumber.class) 
@Cucumber.Options(
    // Enable one of these to run just some tests. Put regexp to match features in here. 
// name = {"^Preview"}, 
// name = {"^Save"}, 
// tags = { "@questionLibrary", "@addingCategory" }, 
    format = {"html:target/cucumber-html-report", "pretty:target/cucumber-json-report.json"}, 
    strict = true 
) 
public class RunCukesTest { 
} 

當Maven運行測試,黃瓜測試運行將找到的所有功能,創建一個漂亮的JUnit測試套件並運行它。這樣,問題就會顯示爲測試失敗。

第二個問題是Cucumber在您的測試中發現錯誤並報告它們。您需要仔細閱讀輸出以瞭解錯誤,然後修復功能描述和/或支持代碼。

+0

我已經有完美執行的runner類,我只有通過命令行運行時遇到問題。我只需要通過命令行來運行它,這樣我就可以使用jenkins輕鬆運行了。 – user1584614 2014-10-03 13:46:32

+0

在這種情況下,您的設置出錯了,因爲Cucumber無法在錯誤輸出結尾附近找到三個步驟定義。 – 2014-10-03 14:15:24