0
setup build.xml for cucumber using maven

Solved 1 Answers 92 Views Programming
0 1
setup build.xml for cucumber using maven, I am creating build.xml and i have to refer to jar file location, since all the jars are in maven,what location i need to use in the below example.

<property name="ws.jars" value="E:\Tools\Selenium\phase2\cucumber\jars"/>

1 Answer

0
Best answer
0
This is how your build.xml should look like.

<project name="java-helloworld" basedir="." default="runcukes">
    <property name="repo" value="https://repo1.maven.org/maven2"/>

    <!-- To figure out compatible combinations of versions, you should examine dependencies in the Maven POM files -->
    <property name="cucumber-jvm.version" value="1.2.4"/>
    <property name="cucumber-jvm-deps.version" value="1.0.5"/>
    <property name="gherkin.version" value="2.12.2"/>
    <property name="cucumber-html.version" value="0.2.3"/>
    <property name="junit.version" value="4.12"/>
    <property name="jars" value="lib"/>

    <target name="download">
        <mkdir dir="${jars}"/>
        <get src="${repo}/info/cukes/cucumber-core/${cucumber-jvm.version}/cucumber-core-${cucumber-jvm.version}.jar"
             dest="${jars}/cucumber-core-${cucumber-jvm.version}.jar"/>
        <get src="${repo}/info/cukes/cucumber-java/${cucumber-jvm.version}/cucumber-java-${cucumber-jvm.version}.jar"
             dest="${jars}/cucumber-java-${cucumber-jvm.version}.jar"/>
        <get src="${repo}/info/cukes/cucumber-junit/${cucumber-jvm.version}/cucumber-junit-${cucumber-jvm.version}.jar"
             dest="${jars}/cucumber-junit-${cucumber-jvm.version}.jar"/>
        <get src="${repo}/info/cukes/cucumber-jvm-deps/${cucumber-jvm-deps.version}/cucumber-jvm-deps-${cucumber-jvm-deps.version}.jar"
             dest="${jars}/cucumber-jvm-deps-${cucumber-jvm-deps.version}.jar"/>
        <get src="${repo}/info/cukes/gherkin/${gherkin.version}/gherkin-${gherkin.version}.jar"
             dest="${jars}/gherkin-${gherkin.version}.jar"/>
        <get src="${repo}/info/cukes/cucumber-html/${cucumber-html.version}/cucumber-html-${cucumber-html.version}.jar"
             dest="${jars}/cucumber-html-${cucumber-html.version}.jar"/>
        <get src="${repo}/junit/junit/${junit.version}/junit-${junit.version}.jar"
             dest="${jars}/junit-${junit.version}.jar"/>
    </target>

    <target name="classpath">
        <path id="classpath">
            <fileset dir="${jars}">
                <include name="**/*.jar"/>
            </fileset>
            <pathelement location="src/test/resources"/>
            <pathelement location="target/classes"/>
            <pathelement location="target/test-classes"/>
        </path>
    </target>

    <target name="compile" depends="classpath">
        <mkdir dir="target/classes"/>
        <javac srcdir="src/main/java" destdir="target/classes" classpathref="classpath" includeantruntime="false"/>
    </target>

    <target name="compile-test" depends="compile,classpath">
        <mkdir dir="target/test-classes"/>
        <javac srcdir="src/test/java" destdir="target/test-classes" classpathref="classpath" includeantruntime="false"/>
    </target>

    <target name="runcukes" depends="compile-test">
        <mkdir dir="target/cucumber-junit-report"/>
        <java classname="cucumber.api.cli.Main" fork="true" failonerror="false" resultproperty="cucumber.exitstatus">
            <classpath refid="classpath"/>
            <arg value="--plugin"/>
            <arg value="junit:target/cucumber-junit-report.xml"/>
            <arg value="--plugin"/>
            <arg value="pretty"/>
            <arg value="--plugin"/>
            <arg value="html:target/cucumber-html-report"/>
            <arg value="--glue"/>
            <arg value="skeleton"/>
            <arg value="src/test/resources"/>
        </java>

        <junitreport todir="target/cucumber-junit-report">
            <fileset dir="target">
                <include name="cucumber-junit-report.xml"/>
            </fileset>
            <report format="frames" todir="target/cucumber-junit-report"/>
        </junitreport>

        <fail message="Cucumber failed">
            <condition>
                <not>
                    <equals arg1="${cucumber.exitstatus}" arg2="0"/>
                </not>
            </condition>
        </fail>
    </target>

    <target name="clean">
        <delete dir="target"/>
    </target>

    <target name="clobber" depends="clean">
        <delete dir="${jars}"/>
    </target>
</project>
answered by
selected by

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
...