当前位置: 首页 > 知识库问答 >
问题:

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

殳飞扬
2023-03-14

我右键点击我的项目,选择“导出..”,在常规文件夹下,然后选择“Ant BuildFiles”。选择您的项目并单击finish(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

buildfile:C:\users\shcr\workspace\mway_tests\BUILD.xml build-subprojects:init:build-projects:[echo]mway_framework:c:\users\shcr\workspace\mway_tests\BUILD.xml BUILD:build-builds:成功生成总时间:429毫秒

共有1个答案

颛孙哲
2023-03-14

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

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

还要确保在build.xml的开头设置了default(与目标名称相同,在本例中为“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>
 类似资料:
  • 我有一个测试,包括jUnit测试和testng测试。它工作正常时,我运行'mvn测试'从父pom,但测试失败时,在jenkins建设。我需要一个方法来跳过詹金斯的测试。

  • 软件版本:jenkins版本1.478 selenium独立版本2.25 chrome驱动程序版本chrome版本21 PHPunit 3.6.10 PHP webdriver绑定http://code.google.com/p/php-webdriver-bindings/Ubuntu11.10使用GUI 概要:在一个新的终端窗口中,我运行java-jar-selenium-server-sta

  • 问题内容: 有没有办法在运行集成测试之前在gradle构建中启动elasticsearch,然后再停止elasticsearch? 到目前为止,我的方法如下,但这阻碍了gradle构建的进一步执行。 问题答案: 出于我的目的,我决定在Java代码的集成测试中开始elasticsearch。 我已经尝试过ElasticsearchIntegrationTest,但是不适用于spring,因为它与Sp

  • 问题内容: 我想调试带有测试的Eclipse构建。我试图通过运行>调试配置> Maven Build来运行它。在Base目录中是我的Maven repo目录,带有pom.xml文件,在目标“全新安装”中。当我单击debug时,Eclipse开始构建,运行测试,但它不会在断点处停止。 问题答案: 我发现最简单的方法是: 右键项目 调试为-> Maven构建 … 在目标字段中, 输入-Dmaven.s

  • 问题内容: 我们将擦除Mac Mini并从头开始重新安装新的XCode和Jenkins。我们最近才开始使用Slack,我们希望使用它来接收Jenkins构建通知并启动Jenkins构建。 因此,Slack通知没有问题。一切正常。 当我尝试使用Slack开始构建时,出现了我的问题。 本教程(http://sonnguyen.ws/how-to-trigger-a-jenkins-build-from