TestNG测试输出文件夹在桌面上生成,而预期在项目文件夹中



我在我的自动化项目中设置了Selenium WebDriver + TestNG + Ant框架。几个月前,在Ant上使用build.xml运行webdriver + TestNG测试是绝对正常的。TestNG按照预期在项目目录中生成了test-output文件夹。

现在,当我从ANT运行测试时,它会在我的桌面(home/user/Desktop)上生成默认的报告文件夹test-output。我不知道为什么会这样。
这是我的build.xml文件:

<project name="InitialConfigProject" default="start" basedir=".">  
<!-- ========== Initialize Properties =================================== -->
<property environment="env"/>
<property file="./app.properties"/>
<property name="ws.home" value="${basedir}"/>
<property name="test.dest" value="${ws.home}/build"/>
<property name="test.src" value="${ws.home}/src"/>
<property name="browser" value="/usr/bin/google-chrome"/>
<property name="mail_body_file" value="${basedir}/email_body.txt"/>
<property name="buildID" value="IND3.2.0"/>
<property name="sendmailscript_path" value="${basedir}/sendmail.sh"/>
<property name="mail_subject" value="Automated_test_execution_of_${buildID}"/>

<!-- ====== Set the classpath ====  -->
<target name="setClassPath" unless="test.classpath">
    <path id="classpath_jars">
        <fileset dir="${ws.home}/lib" includes="*.jar"/>
    </path>
    <pathconvert pathsep=":" property="test.classpath" refid="classpath_jars"/>
</target>


<!-- ============ Initializing other stuff ===========  -->
<target name="init" depends="setClassPath">
    <tstamp>
        <format property="timestamp" pattern="dd/MM/yyyy hh:mm aa" />
    </tstamp>
    <!--
    <condition property="ANT" 
        value="${env.ANT_HOME}/bin/ant.bat" 
        else="${env.ANT_HOME}/bin/ant">
                <os family="windows" />
    </condition> -->
    <property name="build.log.dir" location="${basedir}/buildlogs" />
    <mkdir dir="${build.log.dir}"/>
    <property name="build.log.filename" value="build_${timestamp}.log"/>
    <record name="${build.log.dir}/${build.log.filename}" loglevel="verbose" append="false"/>
    <echo message="build logged to ${build.log.filename}"/>
    <echo message="Loading TestNG.." />
    <taskdef name="testng" classpath="${test.classpath}" classname="org.testng.TestNGAntTask" />
</target>

<!-- cleaning the destination folders -->
<target name="clean">
    <delete dir="${test.dest}"/>
</target>

<!-- compiling files -->
<target name="compile" depends="init, clean" > 
    <delete includeemptydirs="true" quiet="true">
        <fileset dir="${test.dest}" includes="**/*"/>
    </delete>
    <echo message="making directory..."/>
    <mkdir dir="${test.dest}"/>
    <copy file="${ws.home}/app.properties" todir="${ws.home}/build" />
    <copy file="${ws.home}/resources/testdata/testDataSet1.properties" todir="${ws.home}/build" />
    <echo message="compiling source files..."/>
    <javac 
        debug="true" 
        destdir="${test.dest}" 
        srcdir="${test.src}" 
        target="1.6" 
        classpath="${test.classpath}"
        includeantruntime="true"
    >
    </javac>
  </target>

<!-- run -->
<target name="run" depends="compile">
    <testng outputdir="${ws.home}/test-output" classpath="${test.classpath}:${test.dest}" suitename="Praxify Sanity Suite">
       <xmlfileset dir="${ws.home}" includes="testng.xml"/> 
    </testng>
</target>

<!--  ========== Generating reports using XSLT utility ==============    -->
<target name="testng-xslt-report">
        <delete dir="${basedir}/testng-xslt">
        </delete>
        <mkdir dir="${basedir}/testng-xslt">
        </mkdir>
        <xslt in="${basedir}/test-output/testng-results.xml" style="${basedir}/testng-results.xsl" out="${basedir}/testng-xslt/index.html"
             processor="SaxonLiaison">
            <param expression="${basedir}/testng-xslt/" name="testNgXslt.outputDir" />
            <param expression="true" name="testNgXslt.sortTestCaseLinks" />
            <param expression="FAIL,SKIP,PASS,CONF,BY_CLASS" name="testNgXslt.testDetailsFilter" />
            <param expression="true" name="testNgXslt.showRuntimeTotals" />
            <classpath refid="classpath_jars"></classpath>
        </xslt>
</target>

<!-- Starting point of the execution, should be dependent on target "run".
Target sequence will be:
start (not_execute) ==> run (not_execute) ==> compile (not_execute) ==> init (execute) ==> clean (execute)
start (execute) <== testng-xslt-report (execute) <== run (execute) <== compile (execute) <==
Suitable for ANT 1.7. Currently using this ====================== -->

<target name="start" depends="run, testng-xslt-report">
    <tstamp prefix="getTime">
            <format property="TODAY" pattern="MM-dd-yyyyhhmmaa"/>
    </tstamp>
    <echo message="sending report as mail...."/>
    <property name="execution_time" value="${buildID}_${getTime.TODAY}"/>
    <property name="dest_file" value="/home/xtremum/Reports/${execution_time}.zip"/>
    <zip destfile="/home/xtremum/Reports/${execution_time}.zip" basedir="${basedir}/testng-xslt"/>
    <property name="report_attachment_file" value="${dest_file}"/>
    <exec executable="${sendmailscript_path}" newenvironment="false"> 
                <arg value="${mail_subject}"/>
                <arg value="${mail_recipient}"/>
                <arg value="${report_attachment_file}"/>
                <arg value="${mail_body_file}"/> 
    </exec>
 </target>



1. 我正在使用Eclipse Juno。
2. 我已经在Eclipse上安装了TestNG插件,这样我就可以直接从Eclipse中运行测试,只需右键单击TestNG .xml,然后选择run。
3.我已经在我的Ubuntu机器上安装了ant1.7,并将我的ANT_HOME设置为/usr/share/ANT。我在Windows ->首选项-> Ant ->运行时-> Ant Home Entries(默认)中查找,它们似乎引用了Eclipse包(Eclipse/plugins/)内的Ant 1.8.3库(jar)。有什么问题吗?
4. 我通过ant从eclipse运行测试,而不是从命令行。

我没有得到任何构建错误。测试正在执行,但test-output文件夹正在创建在桌面上。任何帮助吗?

如果你正在运行testng插件选项,输出文件夹将是你在Project->Properties-> testng ->OutputDirectory

中指定的文件夹。

相关内容

  • 没有找到相关文章

最新更新