Selenium Ant在Eclipse中构建启动测试但不在jenkins中

时间:2017-05-22 10:55:46

标签: selenium jenkins ant

运行以下内容: Java 1.8,selenium 3.4.0。 ,Ant,Jenkings和使用eclipse IDE

我右键单击我的项目并选择"导出..",在常规文件夹下,然后我选择" Ant Buildfiles"。选择您的项目并单击“完成”(Ant build name =' build.xml')

我右键单击build.xml文件并选择ran as Ant Build。

我收到以下结果:

> Buildfile: C:\Users\shcr\workspace\MWay_Tests\build.xml
> build-subprojects: init: build-project:
>      [echo] MWay_Framework: C:\Users\shcr\workspace\MWay_Framework\build.xml init:
> build-project:
>      [echo] MWay_Tests: C:\Users\shcr\workspace\MWay_Tests\build.xml build: BUILD
> SUCCESSFUL Total time: 429 milliseconds

如果我右键单击Build XML并选择" External Tools Configuration",然后在Targets选项卡下我可以选择我需要的测试。 (确认你的目标订单:" Build,tests,junitreport")如果我点击立即运行,那么它就开始我的测试。

问题是,在詹金斯,我仍然只接受构建成功,但它没有启动硒测试:

  

构建文件:C:\ Users \ shcr \ workspace \ MWay_Tests \ build.xml   build-subprojects:init:build-project:        [echo] MWay_Framework:C:\ Users \ shcr \ workspace \ MWay_Framework \ build.xml init:   建设项目:        [echo] MWay_Tests:C:\ Users \ shcr \ workspace \ MWay_Tests \ build.xml build:BUILD   SUCCESSFUL总时间:429毫秒

1 个答案:

答案 0 :(得分:0)

打开build.xml并在xml底部添加以下内容

<target name="all" depends="build,YourTestName, junitreport"/>

还要确保在build.xml开头设置了默认值(在这种情况下与目标名称相同&#34; all&#34;)

<project basedir="." default="all" name="MWay_Tests">

当我现在在詹金斯运行时,它开始了测试。

这是我的完整build.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- WARNING: Eclipse auto-generated file.
              Any modifications will be overwritten.
              To include a user specific buildfile here, simply create one in the same
              directory with the processing instruction <?eclipse.ant.import?>
              as the first entry and export the buildfile again. --><project basedir="." default="all" name="MWay_Tests">
    <property environment="env"/>
    <property name="junit.output.dir" value="junit"/>
    <property name="MWay_Framework.location" value="../MWay_Framework"/>
    <property name="debuglevel" value="source,lines,vars"/>
    <property name="target" value="1.8"/>
    <property name="source" value="1.8"/>
    <path id="JUnit 4.libraryclasspath">
        <pathelement location="../../../../eclipse/plugins/org.junit_4.12.0.v201504281640/junit.jar"/>
        <pathelement location="../../../../eclipse/plugins/org.hamcrest.core_1.3.0.v201303031735.jar"/>
    </path>
    <path id="javafaker0.1.2.userclasspath">
        <pathelement location="../../../../eclipse/Selenium Library/javafaker-0.12/automaton-1.11-8.jar"/>
        <pathelement location="../../../../eclipse/Selenium Library/javafaker-0.12/commons-lang3-3.5.jar"/>
        <pathelement location="../../../../eclipse/Selenium Library/javafaker-0.12/generex-1.0.2.jar"/>
        <pathelement location="../../../../eclipse/Selenium Library/javafaker-0.12/javafaker-0.12.jar"/>
    </path>
    <path id="oracledriver.userclasspath">
        <pathelement location="../../../../eclipse/Selenium Library/oracle/oracle.jdbc.driver.OracleDriver.jar"/>
    </path>
    <path id="SeleniumJava3.3.1.userclasspath">
        <pathelement location="../../../../eclipse/Selenium Library/selenium-java-3.3.1/client-combined-3.3.1-nodeps.jar"/>
        <pathelement location="../../../../eclipse/Selenium Library/selenium-java-3.3.1/lib/cglib-nodep-3.2.4.jar"/>
        <pathelement location="../../../../eclipse/Selenium Library/selenium-java-3.3.1/lib/commons-codec-1.10.jar"/>
        <pathelement location="../../../../eclipse/Selenium Library/selenium-java-3.3.1/lib/commons-exec-1.3.jar"/>
        <pathelement location="../../../../eclipse/Selenium Library/selenium-java-3.3.1/lib/commons-io-2.5.jar"/>
        <pathelement location="../../../../eclipse/Selenium Library/selenium-java-3.3.1/lib/commons-lang3-3.5.jar"/>
        <pathelement location="../../../../eclipse/Selenium Library/selenium-java-3.3.1/lib/commons-logging-1.2.jar"/>
        <pathelement location="../../../../eclipse/Selenium Library/selenium-java-3.3.1/lib/cssparser-0.9.21.jar"/>
        <pathelement location="../../../../eclipse/Selenium Library/selenium-java-3.3.1/lib/gson-2.8.0.jar"/>
        <pathelement location="../../../../eclipse/Selenium Library/selenium-java-3.3.1/lib/guava-21.0.jar"/>
        <pathelement location="../../../../eclipse/Selenium Library/selenium-java-3.3.1/lib/hamcrest-core-1.3.jar"/>
        <pathelement location="../../../../eclipse/Selenium Library/selenium-java-3.3.1/lib/hamcrest-library-1.3.jar"/>
        <pathelement location="../../../../eclipse/Selenium Library/selenium-java-3.3.1/lib/htmlunit-2.24.jar"/>
        <pathelement location="../../../../eclipse/Selenium Library/selenium-java-3.3.1/lib/htmlunit-core-js-2.23.jar"/>
        <pathelement location="../../../../eclipse/Selenium Library/selenium-java-3.3.1/lib/htmlunit-driver-2.24.jar"/>
        <pathelement location="../../../../eclipse/Selenium Library/selenium-java-3.3.1/lib/httpclient-4.5.2.jar"/>
        <pathelement location="../../../../eclipse/Selenium Library/selenium-java-3.3.1/lib/httpcore-4.4.4.jar"/>
        <pathelement location="../../../../eclipse/Selenium Library/selenium-java-3.3.1/lib/httpmime-4.5.2.jar"/>
        <pathelement location="../../../../eclipse/Selenium Library/selenium-java-3.3.1/lib/javax.servlet-api-3.1.0.jar"/>
        <pathelement location="../../../../eclipse/Selenium Library/selenium-java-3.3.1/lib/jetty-io-9.4.1.v20170120.jar"/>
        <pathelement location="../../../../eclipse/Selenium Library/selenium-java-3.3.1/lib/jetty-util-9.4.1.v20170120.jar"/>
        <pathelement location="../../../../eclipse/Selenium Library/selenium-java-3.3.1/lib/jna-4.1.0.jar"/>
        <pathelement location="../../../../eclipse/Selenium Library/selenium-java-3.3.1/lib/jna-platform-4.1.0.jar"/>
        <pathelement location="../../../../eclipse/Selenium Library/selenium-java-3.3.1/lib/junit-4.12.jar"/>
        <pathelement location="../../../../eclipse/Selenium Library/selenium-java-3.3.1/lib/neko-htmlunit-2.24.jar"/>
        <pathelement location="../../../../eclipse/Selenium Library/selenium-java-3.3.1/lib/phantomjsdriver-1.4.0.jar"/>
        <pathelement location="../../../../eclipse/Selenium Library/selenium-java-3.3.1/lib/sac-1.3.jar"/>
        <pathelement location="../../../../eclipse/Selenium Library/selenium-java-3.3.1/lib/serializer-2.7.2.jar"/>
        <pathelement location="../../../../eclipse/Selenium Library/selenium-java-3.3.1/lib/websocket-api-9.2.20.v20161216.jar"/>
        <pathelement location="../../../../eclipse/Selenium Library/selenium-java-3.3.1/lib/websocket-client-9.2.20.v20161216.jar"/>
        <pathelement location="../../../../eclipse/Selenium Library/selenium-java-3.3.1/lib/websocket-common-9.2.20.v20161216.jar"/>
        <pathelement location="../../../../eclipse/Selenium Library/selenium-java-3.3.1/lib/xalan-2.7.2.jar"/>
        <pathelement location="../../../../eclipse/Selenium Library/selenium-java-3.3.1/lib/xercesImpl-2.11.0.jar"/>
        <pathelement location="../../../../eclipse/Selenium Library/selenium-java-3.3.1/lib/xml-apis-1.4.01.jar"/>
    </path>
    <path id="opencsv.userclasspath">
        <pathelement location="../../../../eclipse/Selenium Library/opencsv/opencsv-3.9.jar"/>
    </path>
    <path id="MWay_Framework.classpath">
        <pathelement location="${MWay_Framework.location}/bin"/>
        <path refid="javafaker0.1.2.userclasspath"/>
        <path refid="oracledriver.userclasspath"/>
        <path refid="SeleniumJava3.3.1.userclasspath"/>
        <path refid="opencsv.userclasspath"/>
    </path>
    <path id="MWay_Tests.classpath">
        <pathelement location="bin"/>
        <path refid="JUnit 4.libraryclasspath"/>
        <path refid="MWay_Framework.classpath"/>
    </path>
    <target name="init">
        <mkdir dir="bin"/>
        <copy includeemptydirs="false" todir="bin">
            <fileset dir="src">
                <exclude name="**/*.launch"/>
                <exclude name="**/*.java"/>
            </fileset>
        </copy>
    </target>
    <target name="clean">
        <delete dir="bin"/>
    </target>
    <target depends="clean" name="cleanall">
        <ant antfile="Environment.xml" dir="${MWay_Framework.location}" inheritAll="false" target="clean"/>
    </target>
    <target depends="build-subprojects,build-project" name="build"/>
    <target name="build-subprojects">
        <ant antfile="Environment.xml" dir="${MWay_Framework.location}" inheritAll="false" target="build-project">
            <propertyset>
                <propertyref name="build.compiler"/>
            </propertyset>
        </ant>
    </target>
    <target depends="init" name="build-project">
        <echo message="${ant.project.name}: ${ant.file}"/>
        <javac debug="true" debuglevel="${debuglevel}" destdir="bin" includeantruntime="false" source="${source}" target="${target}">
            <src path="src"/>
            <classpath refid="MWay_Tests.classpath"/>
        </javac>
    </target>
    <target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
    <target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
        <copy todir="${ant.library.dir}">
            <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
        </copy>
        <unzip dest="${ant.library.dir}">
            <patternset includes="jdtCompilerAdapter.jar"/>
            <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
        </unzip>
    </target>
    <target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
        <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
        <antcall target="build"/>
    </target>

    <target name="testSuiteEnvironment">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="testSuite.testSuiteEnvironment" todir="${junit.output.dir}"/>
            <jvmarg line="-ea"/>
            <classpath refid="MWay_Tests.classpath"/>
        </junit>
    </target>


    <target name="junitreport">
        <junitreport todir="${junit.output.dir}">
            <fileset dir="${junit.output.dir}">
                <include name="TEST-*.xml"/>
            </fileset>
            <report format="frames" todir="${junit.output.dir}"/>
        </junitreport>
    </target>

    <target name="all" depends="build,testSuiteEnvironment, junitreport"/>

</project>