Selenium Ant 构建在 Eclipse 中开始测试,但不在 jenkins 中开始测试



运行以下命令:Java 1.8,Selenium 3.4.0。

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

我右键单击构建.xml文件并选择作为 Ant 构建运行。

我收到以下结果:

> Buildfile: C:UsersshcrworkspaceMWay_Testsbuild.xml
> build-subprojects: init: build-project:
>      [echo] MWay_Framework: C:UsersshcrworkspaceMWay_Frameworkbuild.xml init:
> build-project:
>      [echo] MWay_Tests: C:UsersshcrworkspaceMWay_Testsbuild.xml build: BUILD
> SUCCESSFUL Total time: 429 milliseconds

如果我右键单击"构建XML"并选择"外部工具配置",则可以在"目标"选项卡下选择所需的测试。(确认您的目标订单:"构建、测试、临时报告")如果单击"立即运行",则会启动我的测试。

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

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

毫秒

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

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

还要确保在构建开始时设置默认值(在本例中为"all",与目标名称相同.xml

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

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

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

最新更新