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

Published Friday, December 17, 2010 8:59 PM by thangchung

Comments

# re: Generating Report for NUnit

Wednesday, July 13, 2011 2:00 AM by Nainesh

But please give the steps to generate the Build file.

# re: Generating Report for NUnit

Friday, July 22, 2011 4:47 AM by thangchung

Hi Nainesh,

Please follow this link for getting the build file you need. github.com/.../BuildFiles . Make sure you change your path fix with your machine.

# re: Generating Report for NUnit

Wednesday, October 12, 2011 8:24 AM by Mihir

Thanks thangchung

This post really helped me to generate the test results Report.

Again Thanks :):)

# re: Generating Report for NUnit

Friday, October 14, 2011 4:10 PM by MN

How to create Build File and Bat File

# re: Generating Report for NUnit

Wednesday, November 16, 2011 4:02 AM by EmilyL

This is really cool for testing. Thx

# re: Generating Report for NUnit

Tuesday, January 31, 2012 6:45 AM by Sam

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.

# re: Generating Report for NUnit

Monday, February 6, 2012 4:57 AM by thangchung

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

# re: Generating Report for NUnit

Monday, February 13, 2012 6:01 AM by Manju

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?

# re: Generating Report for NUnit

Monday, February 27, 2012 8:03 AM by Sid

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

# re: Generating Report for NUnit

Monday, February 27, 2012 8:10 AM by Sid

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

# re: Generating Report for NUnit

Monday, February 27, 2012 12:00 PM by 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

# re: Generating Report for NUnit

Tuesday, September 11, 2012 8:02 AM by Pritesh

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

Is there any way to do this?

# re: Generating Report for NUnit

Monday, September 24, 2012 5:04 PM by Luiz Diego

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

# re: Generating Report for NUnit

Monday, December 31, 2012 7:57 AM by Cullen

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.

# re: Generating Report for NUnit

Tuesday, January 1, 2013 10:06 AM by Caswell

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.

# re: Generating Report for NUnit

Wednesday, January 2, 2013 3:02 AM by Maness

What tops your tree. ) relic. Utilize great tiongkok along with cups

instead of disposable discs, cups, and also plastic material utensils.

# re: Generating Report for NUnit

Tuesday, January 8, 2013 6:10 AM by Breeden

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.

# re: Generating Report for NUnit

Tuesday, February 5, 2013 6:01 AM by M.P.Singh

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

# re: Generating Report for NUnit

Tuesday, March 26, 2013 1:49 PM by Brinson

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.

# re: Generating Report for NUnit

Wednesday, March 27, 2013 1:00 AM by Kirkland

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.

# re: Generating Report for NUnit

Wednesday, March 27, 2013 1:40 AM by Edge

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

# re: Generating Report for NUnit

Wednesday, March 27, 2013 11:45 AM by Dempsey

I couldn't resist commenting. Well written!

# re: Generating Report for NUnit

Wednesday, March 27, 2013 7:19 PM by Swenson

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?

# re: Generating Report for NUnit

Wednesday, April 3, 2013 7:32 AM by Belt

Way cool! Some extremely valid points! I appreciate you penning this post and the rest of the

website is also very good.

# re: Generating Report for NUnit

Friday, April 12, 2013 9:41 AM by Fine

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