2016-04-04 53 views
0

我正在部署使用螞蟻的黃瓜測試。 Ant會生成報告,但是這些測試的狀態會被跳過,並且場景顯示它未定義。 我想知道這是我的亞軍班的問題嗎?黃瓜測試沒有運行使用螞蟻?

我的代碼:

package cucumber; 

import org.junit.runner.RunWith; 

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

@RunWith(Cucumber.class) 
@CucumberOptions(, 
     plugin = {"html:target/cucumber-html-report","junit:target/cucumber-junit-report/test.xml"}, 
     features = {"src/cucumber/features"}) 
public class CucumberRunner { 

} 

我的build.xml

<!-- Build targets --> 
<target name="build" description="Build project" depends="clean,compile,package"/> 
<target name="test" description="Test project" depends="build"> 
     <mkdir dir="target/cucumber-junit-report"/> 
     <java classname="cucumber.api.cli.Main" fork="true" failonerror="false" resultproperty="cucumber.exitstatus"> 
      <classpath refid="test.classpath"/> 
      <arg value="--format"/> 
      <!-- creates our junit report --> 
      <arg value="junit:target/cucumber-junit-report/test.xml"/> 
      <arg value="--format"/> 
      <arg value="pretty"/> 
      <arg value="--format"/> 
      <!-- creates our cucumber html friendly report --> 
      <arg value="html:target/cucumber-html-report"/> 
      <arg value="--format"/> 
      <!-- creates our cucumber json friendly report --> 
      <arg value="json:target/cucumber.json"/> 
      <arg value="--glue"/> 
      <!-- identifies the package (folder) where the cucumber definitions live --> 
      <arg value="test.src.cucumber.features"/> 
      <!-- identifies the folder where the feature files live (looks in all subfolders) --> 
      <arg value="test/src/cucumber"/> 
     </java> 

     <!-- writes out information to junit report --> 
     <junitreport todir="target/cucumber-junit-report"> 
      <fileset dir="target/cucumber-junit-report"> 
       <include name="test.xml"/> 
      </fileset> 
      <report format="frames" todir="target/cucumber-junit-report"/> 
     </junitreport> 

     <!-- checks our exit status, and determines success or failure --> 
     <fail message="Cucumber failed"> 
      <condition> 
       <not> 
        <equals arg1="${cucumber.exitstatus}" arg2="0"/> 
       </not> 
      </condition> 
     </fail> 
    </target>  

回答

0

快速瀏覽一下你亞軍類不告訴我,這是壞了。

但是,我會減少這個問題,並從一些有效的工作開始。在這種情況下,我會克隆https://github.com/cucumber/cucumber-java-skeleton或將其下載爲zip並查看它是否有效。然後我會介紹你一步一步的東西。非常小的步驟,並始終驗證場景是否正確執行。

你有一些問題,至少在我看來,你有很多事情在你的構建中進行。

還記得加爾定律: 「工作的複雜系統總是從一個簡單的系統發展而來,一個複雜的系統從頭開始設計,永遠不會工作,不能修補以使其工作。完成一個簡單的系統。「

0

我認爲你必須擴展類似於此

public class TestRunner extends AbstractTestNGCucumberTests { 
抽象測試類