Generating Report for NUnit

 All source codes for this post can be found at my github.

Time ago, I received a request that people ask me how they can generate reports of the results of testing using NUnit? In fact, I may never do this. In the little world of my programming, I only care about the test results, red-green-refactoring, and that was it. When I got that question quite a bit unexpected, I knew that I could use NCover to generate reports, but reports of NCover too simple, it did not give us more details on the number of test cases, test methods, ...

And I began to see about creating interesting report for NUnit.I was lucky to find an open source here. Its authors call it NUnit2Report, but one disadvantage is it only running on .NET 1.0. Indeed too old compared to the current version 4.0. And I try to download the preview, but I could not run. I had to open its source code and found that it uses XSLT to convert the output of NUnit results from XML to HTML. Nothing really special, because I also knew that after NUnit run output file extension is XML is created. Author only use this file to convert to HTML using XSLT. And I decided to convert it to. NET 4.0, because I will not have to code from scratch. Conversion work made me take some time, but was lucky that I finally have what I want. Thanks Gilles for the this OSS. I will send a mail to thank him for his efforts but put this out for the OSS. Now I will show people how to do it. I used the auto built NAnt and NUnit for running TestCase, and I use Selenium testing framework. After writing three TestCase using Selenium, I ran NUnit, and got the following results:


There are 1 fail and 2s success. In the bin directory of this project will have the NUnit output file as shown below:


Then I create a build file, and a bat file for easy running (can use PowerShell is here also.) Double click in the bat file to create a report like this:

 

 

 

Finally open the index.html file in the folder to view report.


As everyone can see, it is the TestCase and divide very clearly, that I meet the requirements. This is really good.

Once again I really thank NUnit2Report from Gilles. People can contact him via the mail address gilles.bayon@laposte.net or website  http://nunit2report.sourceforge.net. It really is useful to those who promised to QA. Hopefully this post will help anyone really interested in doing reports for NUnit.

Shout it   kick it on DotNetKicks.com

25 Comments

  • But please give the steps to generate the Build file.

  • Hi Nainesh,
    Please follow this link for getting the build file you need. https://github.com/thangchung/NUnit2Report/tree/master/Sample/TestSelenium2/BuildFiles . Make sure you change your path fix with your machine.

  • Thanks thangchung
    This post really helped me to generate the test results Report.
    Again Thanks :):)

  • How to create Build File and Bat File

  • This is really cool for testing. Thx

  • Hi.

    I've got following error when I run the bat file.

    "BUILD FAILED

    Property name 'sys.env.CommonProgramFiles(x86)' is invalid."

    I'm working on 64bit Win7 machine.

    Thanks.

  • It's really cool when you found it was interesting.

  • I've got following error when I run the bat file.

    "BUILD FAILED

    Property name 'sys.env.CommonProgramFiles(x86)' is invalid."

    I'm working on 64bit Win7 machine.

    Can you please tell us some solution for it?

  • Hi,
    I am trying to do the same as done above to generate the detail report on Win7, 32 bit, .Net 4 framework. When I am executing the build.bat file the screen comes up with 'Press any key to continue...' when I press any key the command prompt goes away and the new folders and index.html file is not created. Can you pleae provide through some light on why I am not able to get the report?
    Your help is highly appreciated.
    Thanks,
    Shahid

  • Hi, just to add to my earlier question .... It gives ' Build Failed' and states the location which is not correct as it states Error loading buildfile. Where do I need to change this?
    I have provided proper location in the 'Build.bat' file.
    Your help is highly appreciated.
    Thanks,
    Sid

  • Hi,
    My problem has been solved... This is the solution to all the users facing similar problem of:
    'System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=4.0.0.0, Culture=neutral,
    PublicKeyToken=b77a5c561934e089' failed.'

    When you copy the following NUnit2Report files to the NAnt bin folder, they are in a protected state. So, you need to right click & open properties and click on Unblock and click OK. The files to be copied over from NUnit2Report to NAnt are: NUnit-Frame.xsl
    NUnit-NoFrame.xsl
    toolkit.xsl
    i18n.xsl
    Traductions.xml
    NAnt.NUnit2ReportTasks.dll

    Hope this helps.... :)
    Sid

  • How to run batch file automatically after running all the tests in nunit?

    Is there any way to do this?

  • Hi I did not like the file .html is called. And where these files should be, whether they should be in the folder with the project or in a directory on disk being referenced.
    thank you

  • They know they won't have to worry about problems most of the time. But there a host of luxury watches that are affordable and not necessarily limited editions that can be purchased without having to spend an alarming and jaw dropping amount as well. Wheather you would like an elegant timepiece, a classic or a sporty one, when you can invest some time and take into account every one of the benefits and drawbacks, all of the facets of the acquisition.

  • Gum. Certain individuals will resent the fact that the person got
    a gift that was far above the monetary value intended in the
    exchange. a mysterious personage who, in the bleak light of dawn one Christmas morning, stumbled on a foundling - a baby camera
    tenderly wrapped in a little travel rug and gently place in a tiny wicker sleigh, discretely
    left at her front door.

  • What tops your tree. ) relic. Utilize great tiongkok along with cups
    instead of disposable discs, cups, and also plastic material utensils.

  • President, I think you’ll agree, this would probably put an end to all
    the name-calling that Democrats are currently subjected to thanks
    to our donkey symbol. Pets as presents seem like a great idea, but the logistics of owning a pet came
    be very tricky. Three, have some fun while searching.

  • Can any one help me to generate report from NUNIT test.xml to HTML by, i am using NUNIT 2.6.2 from initial to end.

    Thanks In Advance

  • Pretty section of content. I just stumbled upon your blog and in accession
    capital to assert that I acquire in fact enjoyed account your blog posts.
    Any way I will be subscribing to your augment and even I achievement
    you access consistently quickly.

  • Every weekend i used to pay a visit this web page, as i want enjoyment,
    for the reason that this this web site conations genuinely nice funny stuff too.

  • Wow, that's what I was seeking for, what a material! existing here at this webpage, thanks admin of this site.

  • I couldn't resist commenting. Well written!

  • Right now it looks like Drupal is the top blogging platform out
    there right now. (from what I've read) Is that what you are using on your blog?

  • Way cool! Some extremely valid points! I appreciate you penning this post and the rest of the
    website is also very good.

  • I really like your blog.. very nice colors & theme. Did you create this
    website yourself or did you hire someone to do it
    for you? Plz respond as I'm looking to create my own blog and would like to find out where u got this from. thank you

Comments have been disabled for this content.