You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Shin ta <sh...@gmail.com> on 2013/06/06 10:21:35 UTC

Automate saving reports using ANT in multiple folder/directory

Hi, i am trying to run a testng.xml file whereby i will get to automate the
saving of reports using build.xml
However i am not too sure how to use ANT. This will be my first ANT
project. Any advice will be appreciated.
my build.xml are as followed:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="build" name="Test_report">

   <!-- Sets variables which can later be used. -->
   <!-- The value of a property is accessed via ${} -->
   <property name="src.dir" location="src" />
   <property name="testng_output.dir" location="testng_output" />
   <property name="test-output.dir" location="test-output" />

<path id="Test_report.classpath">
<fileset dir="${lib.dir}">
      <include name="**/*.jar" />
    </fileset>
</path>

      <target name="clean">
      </target>

      <target name="makedir">
       <mkdir dir="testng_output" />
      </target>

      <target name="testng_output" depends= "makedir">
       <testng outputdir="testng_output"
classpathref="Test_report.classpath">
           <xmlfileset dir="." includes="testng.xml"/>
           </testng>
      </target>
  <target name="setTimeStampReportDir" depends="testng_output">
        <tstamp>
            <format property="tstmp" pattern="MM_dd_yyyy" locale="en"/>
        </tstamp>
     <property name="cur.report.dir" value="./run_${date}"/>
 </target>
 <presetdef name="my.javac">
   <javac debug="${debug}" deprecation="${deprecation}"
          srcdir="${src.dir}" destdir="${classes.dir}">
      <src path="${gen.dir}"/>
   </javac>
</presetdef>
      <target name="build" depends="setTimeStampReportDir">
        <description>Build target</description>
      </target>

    </project>

After i run it, it gave me this error:
Cause: The name is undefined. Action: Check the spelling. Action: Check
that any custom tasks/types have been declared. Action: Check that any
<presetdef>/<macrodef> declarations have taken place.

AW: Automate saving reports using ANT in multiple folder/directory

Posted by "Jan Matèrne (jhm)" <ap...@materne.de>.
TestNG is not supported by Ant directly.
So you have to declare the task and its location.

See
http://testng.org/doc/ant.html

So place a <taskdef> e.g. after <project> tag.
But I would change a little bit more ...


Jan


<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="build" name="Test_report">
  <property name="src.dir" location="src" />
  
  <!-- 
  Use a common root folder for generated artefacts. 
  So you could simple delete this directory. 
  Also you dont have to check it into a VCS. 
  -->
  <property name="build.dir" value="build"/>
  
  <!-- paths relative to that build directory -->
  <property name="testng_output.dir" location="${build.dir}/testng_output"
/>
  <property name="test-output.dir" location="${build.dir}/test-output" />
  
  <!-- Set the TestNG.jar-location via property -->
  <property name="testng.location" location="testng.jar">

  <path id="Test_report.classpath">
    <!-- where do you define the lib.dir? -->
    <fileset dir="${lib.dir}">
      <include name="**/*.jar" />
    </fileset>
  </path>
  
  <target name="clean">
    <!-- because of the common build dir, just do a -->
    <delete dir="${build.dir}"/>
  </target>
  
  <target name="testng_output">
    <!-- inlined into this target; use of the property -->
    <mkdir dir="${testng_output.dir}" />
    <!-- declare the task before using it -->
    <taskdef resource="testngtasks" classpath="${testng.location}"/>
    <!-- use the property -->
    <testng outputdir="${testng_output.dir}"
classpathref="Test_report.classpath">
      <xmlfileset dir="." includes="testng.xml"/>
    </testng>
  </target>
  
  <target name="setTimeStampReportDir" depends="testng_output">
    <tstamp>
      <format property="tstmp" pattern="MM_dd_yyyy" locale="en"/>
    </tstamp>
    <!-- is the property 'date' defined somewhere else? -->
    <!-- maybe you mean 'tstmp' or 'DSTAMP' -->
    <!-- see http://ant.apache.org/manual/Tasks/tstamp.html -->
    <property name="cur.report.dir" value="./run_${date}"/>
  </target>
  
  <presetdef name="my.javac">
    <javac debug="${debug}" deprecation="${deprecation}" srcdir="${src.dir}"
destdir="${classes.dir}">
      <src path="${gen.dir}"/>
    </javac>
  </presetdef>
  
  <target name="build" depends="setTimeStampReportDir">
    <description>Build target</description>
  </target>
</project>





> -----Ursprüngliche Nachricht-----
> Von: Shin ta [mailto:shinta3c@gmail.com]
> Gesendet: Donnerstag, 6. Juni 2013 10:22
> An: user@ant.apache.org
> Betreff: Automate saving reports using ANT in multiple folder/directory
> 
> Hi, i am trying to run a testng.xml file whereby i will get to automate
> the saving of reports using build.xml However i am not too sure how to
> use ANT. This will be my first ANT project. Any advice will be
> appreciated.
> my build.xml are as followed:
> <?xml version="1.0" encoding="UTF-8" standalone="no"?> <project
> basedir="." default="build" name="Test_report">
> 
>    <!-- Sets variables which can later be used. -->
>    <!-- The value of a property is accessed via ${} -->
>    <property name="src.dir" location="src" />
>    <property name="testng_output.dir" location="testng_output" />
>    <property name="test-output.dir" location="test-output" />
> 
> <path id="Test_report.classpath">
> <fileset dir="${lib.dir}">
>       <include name="**/*.jar" />
>     </fileset>
> </path>
> 
>       <target name="clean">
>       </target>
> 
>       <target name="makedir">
>        <mkdir dir="testng_output" />
>       </target>
> 
>       <target name="testng_output" depends= "makedir">
>        <testng outputdir="testng_output"
> classpathref="Test_report.classpath">
>            <xmlfileset dir="." includes="testng.xml"/>
>            </testng>
>       </target>
>   <target name="setTimeStampReportDir" depends="testng_output">
>         <tstamp>
>             <format property="tstmp" pattern="MM_dd_yyyy" locale="en"/>
>         </tstamp>
>      <property name="cur.report.dir" value="./run_${date}"/>  </target>
> <presetdef name="my.javac">
>    <javac debug="${debug}" deprecation="${deprecation}"
>           srcdir="${src.dir}" destdir="${classes.dir}">
>       <src path="${gen.dir}"/>
>    </javac>
> </presetdef>
>       <target name="build" depends="setTimeStampReportDir">
>         <description>Build target</description>
>       </target>
> 
>     </project>
> 
> After i run it, it gave me this error:
> Cause: The name is undefined. Action: Check the spelling. Action: Check
> that any custom tasks/types have been declared. Action: Check that any
> <presetdef>/<macrodef> declarations have taken place.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org