【问题标题】:Selenium Ant build start tests in Eclipse but not in jenkinsSelenium Ant 在 Eclipse 中构建开始测试,但在 jenkins 中没有
【发布时间】:2017-10-22 00:10:13
【问题描述】:

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

我右键单击我的项目并在 General 文件夹下选择“Export..”,然后选择“Ant Buildfiles”。选择你的项目并点击完成(Ant build name = 'build.xml')

我右键单击 build.xml 文件并选择作为 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

如果我右键单击构建 XML 并选择“外部工具配置”,然后在“目标”选项卡下,我可以选择所需的测试。 (确认你的目标顺序:“Build, tests, junitreport”)如果我点击 Run now,那么它就会开始我的测试。

问题是在 Jenkins 中我仍然只收到构建成功但它没有启动硒测试:

构建文件:C:\Users\shcr\workspace\MWay_Tests\build.xml 构建子项目:初始化:构建项目: [回声] MWay_Framework: C:\Users\shcr\workspace\MWay_Framework\build.xml 初始化: 构建项目: [回声] MWay_Tests:C:\Users\shcr\workspace\MWay_Tests\build.xml 构建:构建 成功总时间:429毫秒

【问题讨论】:

    标签: selenium jenkins ant


    【解决方案1】:

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

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

    还要确保在 build.xml 的开头设置了默认值(在本例中为“all”,与您的目标名称相同)

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

    当我现在在 jenkins 中运行它时,它开始了测试。

    这是我完整的 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>
    

    【讨论】:

      猜你喜欢
      • 2017-08-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-28
      • 1970-01-01
      • 1970-01-01
      • 2020-09-21
      相关资源
      最近更新 更多