Search code examples
nunitreportnant

How to create a report with a different name each time by nunit2report?


I use Nant genrate Nunit Report by nunit2report.

And everyday it build it will replace the old one.

How can I generate report with different like:

TestReport_0815.html
TestReport_0816.html
....

Here is my build file:

<?xml version="1.0"?>
<project name="dotNet_Login" default="build" basedir=".">
  <property name="nant.settings.currentframework" value="net-4.0"/>

  <target name="build">
    <solution configuration="debug" solutionfile="Test_Login\Test_Login.sln" />
  </target>

  <target name="run" depends="build">
    <exec program="Nunit\NUnit-2.6.0.12051\bin\nunit-console.exe">
       <arg value="dotNet_Login\dotNet_Login\bin\debug\dotNet_Login.dll" />
    </exec>

    <nunit2report out="NUnitReport.html">
      <fileset>
        <includes name="TestResult.xml" />
      </fileset>
    </nunit2report>

    <echo message="NUnit report generated."/>
  </target>

</project>

Solution

  • You can try something like this:

    <tstamp property="revision" pattern="yyMMdd" />
    
    <nunit2report out="TestReport_${revision}.html">
       ...
    </nunit2report>
    

    This will result in file names like this:

    TestReport_120815.html
    TestReport_120816.html
    TestReport_120817.html
    ...
    

    You can play with the <tstamp/> task to get the output file name you'd like.