本文介绍了Ant - 继续执行目标,即使一个目标完成了硒自动化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法让 Ant 即使一个目标完成也不会退出?

Is there a way to cause Ant to not quit even if one of a target completes?

例如,可能执行多个目标,如果第一个停止,selenium 将冻结.所有其他目标中并行运行的其他测试用例停止.

For instance, several targets may execute, and if the first one stops,selenium will freeze.All the other testcases which are running parallel in other target stops.

如何让蚂蚁继续执行其他目标,即使完成了.

How to make ant to continue executing other targets,even if one completes.

我尝试在目标级别给出 -k ,但没有用.我们将 failonerror 设置为 true .这有关系吗?

I tried giving -k at target level , but no use. We have failonerror set to true .Does that matter?

这是我的构建文件:

<target name="startServerRC" depends="startServerhub">
        <echo>Starting Selenium Server...</echo>
        <java jar="${lib.dir}/selenium-server-standalone.jar" fork="true" spawn="true">
            <arg line="-port 5555"/>
            <arg line="-log log.txt"/>  
            <arg line="-firefoxProfileTemplate"/>
            <arg value="${lib.dir}/ff_profile"/>
            <arg line="-userExtensions"/>
                <arg value="${lib.dir}/user-extensions.js"/>
            <arg line="-role node"/>
            <arg line="-hub http://localhost:4444/grid/register "/>
            <arg line="-maxSession 10"/>
            <arg line="-maxInstances=10"/>
        </java>
    </target>

        <!-- Initialization -->
    <target name="init" depends="startServerRC" >
        <echo>Initlizing...</echo>
        <delete dir="${classes.dir}" />
        <mkdir dir="${classes.dir}"/>
    </target>

    <!-- Complies the java files -->
    <target name="compile" depends="init">
        <echo>Compiling...</echo>
        <javac 
            debug="true" 
            srcdir="${src.dir}" 
            destdir="${classes.dir}"   
            classpathref="classpath" />
    </target>

    <target name="CItarget">    
        <sequential>
            <antcall target="compile"/>
            <parallel> 
              <antcall target="run"/>
              <antcall target="run_PSDATA"/>
            </parallel>
            <parallel> 
                <antcall target="run_PreData"/> 
                <antcall target="run_DFPPulls"/> 
                <antcall target="run_AdTechPulls"/> 
                <antcall target="run_AppnexusPulls"/> 
                <antcall target="run_FTPPulls"/> 
                <antcall target="run_OASPulls"/> 
                <antcall target="run_GDFPPulls"/> 
                <antcall target="run_FreewheelPulls"/> 
                <antcall target="run_ThirdPartyPulls"/> 
            </parallel>
            <parallel>
        <antcall target="run_PostData"/> 
                <antcall target="run_Sales"/> 
            </parallel>
            <parallel>
                <antcall target="run_Administration"/> 
                <antcall target="run_E2EPartner360"/> 
                <antcall target="run_Sales"/> 
                <antcall target="run_Finance"/> 
                <antcall target="run_Loaders"/> 
                <antcall target="run_Accounts"/> 
                <antcall target="run_Adops"/> 
            </parallel>
            <parallel>
                <antcall target="run_Alerts"/> 
                <antcall target="run_CustomFields"/> 
            </parallel>
            <antcall target="stop-selenium"/>
       </sequential>
    </target>

提前致谢

推荐答案

您可以尝试使用 try-catch 来自 ant-contrib.

You could try using try-catch from ant-contrib.

来自链接的示例:

<trycatch property="foo" reference="bar">
  <try>
    <fail>Tada!</fail>
  </try>

  <catch>
    <echo>In &lt;catch&gt;.</echo>
  </catch>

  <finally>
    <echo>In &lt;finally&gt;.</echo>
  </finally>
</trycatch>

如果某件事失败了,你只会回应某事(或做笔记).如果您需要确保服务器在最后关闭,即使中间出现严重故障,finally 部分也能很好地工作.

If someting fails, you would just echo something (or do noting). The finally part works great if you need to make sure, that servers are shut down at the end, even if something fails hard in between.

同时设置 failonerror="false" 应该使 ant 不会因错误而导致构建失败.

Also setting failonerror="false" should make ant not to fail the build on errors.

这篇关于Ant - 继续执行目标,即使一个目标完成了硒自动化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 19:07