Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Selenium Ant构建启动测试在Eclipse中进行,但不在jenkins中进行_Selenium_Jenkins_Ant - Fatal编程技术网

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

Selenium Ant构建启动测试在Eclipse中进行,但不在jenkins中进行,selenium,jenkins,ant,Selenium,Jenkins,Ant,运行以下命令:Java 1.8、selenium 3.4.0,Ant、Jenkings和使用EclipseIDE 我右键单击我的项目并选择“导出…”,然后在“常规”文件夹下选择“Ant Buildfiles”。选择您的项目并单击finish(Ant构建名称='build.xml') 我右键单击build.xml文件并选择RunasAntBuild 我收到以下结果: > Buildfile: C:\Users\shcr\workspace\MWay_Tests\build.xml >

运行以下命令:Java 1.8、selenium 3.4.0,Ant、Jenkings和使用EclipseIDE

我右键单击我的项目并选择“导出…”,然后在“常规”文件夹下选择“Ant Buildfiles”。选择您的项目并单击finish(Ant构建名称='build.xml')

我右键单击build.xml文件并选择RunasAntBuild

我收到以下结果:

> 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
如果我右键单击buildxml并选择“externaltoolsconfiguration”,那么在Targets选项卡下,我可以选择所需的测试。(确认您的目标顺序:“构建、测试、junitreport”)如果我单击“立即运行”,那么它将启动我的测试

问题是,在Jenkins中,我仍然只收到构建成功的消息,但它不会启动selenium测试:

构建文件:C:\Users\shcr\workspace\MWay\u Tests\build.xml 生成子项目:初始化:生成项目: [echo]MWay\u Framework:C:\Users\shcr\workspace\MWay\u Framework\build.xml init: 建设项目: [echo]MWay\u测试:C:\Users\shcr\workspace\MWay\u测试\build.xml构建:build 成功总时间:429毫秒


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

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

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

<project basedir="." default="all" name="MWay_Tests">
<?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>

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

这是我的完整build.xml

<project basedir="." default="all" name="MWay_Tests">
<?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>