Customizing NUnit XML output

410 views
Skip to first unread message

andreister

unread,
Feb 8, 2010, 9:55:47 AM2/8/10
to NUnit-Discuss
I'm looking at NUnit XML output right now, and wonder if it's possible
to generate the output for failures only. I.e., if a test passes ok,
no XML output gets generated for it at all.

**NOTE**: XSLT is not an option here. If I don't need the details
about the passed tests, I don't want the system to spend time
generating those details.

The idea is, XML output tend to be quite large if you have a lot of
tests, but 80% of the time you're after failures anyway. For such
cases, I'd like to run my tests "in a light way" and spend as little
time as possible in XML generation.

Charlie Poole

unread,
Feb 8, 2010, 12:05:35 PM2/8/10
to nunit-...@googlegroups.com
Hi,

Just a quick check of mail before the next leg of my trip.

Thought I'd comment a bit on this one since it impacts ongoing
development of NUnit 3.0 as well...

> I'm looking at NUnit XML output right now, and wonder if it's
> possible to generate the output for failures only. I.e., if a
> test passes ok, no XML output gets generated for it at all.

Currently, there is no such option.



> **NOTE**: XSLT is not an option here. If I don't need the
> details about the passed tests, I don't want the system to
> spend time generating those details.
>
> The idea is, XML output tend to be quite large if you have a
> lot of tests, but 80% of the time you're after failures
> anyway. For such cases, I'd like to run my tests "in a light
> way" and spend as little time as possible in XML generation.

The best way to contribute to any changes in the XML output
right now is probably to involve yourself in ongoing discussions
about the next version of NUnit. Like database formats, xml
output formats tend to change very slowly because so many people
depend on them.

Of course, it would be possible to add a switch that modifies
how xml is generated, without changing the basic format. My
guess is that few people would consider this a high priority,
for the following reasons:

1. The time that NUnit spends generating XML is rather trivial,
in comparison to the length of the run.

2. If you just want a quick result while developing, most people
just run (or even just load) a subset of the tests.

3. It's an even easier fix (and I think alread requested) to just
suppress the XML output entirely and rely on the console text
output - which is currently independent.

Of course, on the question of how important this may be to others,
I could easily be wrong. What do folks think?

Charlie

> --
> You received this message because you are subscribed to the
> Google Groups "NUnit-Discuss" group.
> To post to this group, send email to nunit-...@googlegroups.com.
> To unsubscribe from this group, send email to
> nunit-discus...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/nunit-discuss?hl=en.
>
>

Ron Rudman

unread,
Feb 9, 2010, 9:51:05 AM2/9/10
to NUnit-Discuss
I also only care about output for failed tests. I'd prefer it if I
could just switch the passed test output off at the source, but I
could live with suppressing it myself, since the result is the same.
What I *would* like to see is a way for me to insert my own text into
the output, e.g., as <NOTES>. I am doing functional testing and would
like the output of my failed tests to include my own aids to reproduce
the result manually.

Johnson, Paul (PS)

unread,
Feb 9, 2010, 10:58:27 AM2/9/10
to nunit-...@googlegroups.com
Charlie

Wondered if you have any sample code for using NUnit expected
exception assertions in VB.NET. I have spent a couple of really
frustrating hours attempting to get them working to my satisfaction. I
am using 2.5.3 of NUnit under VS2005, the only technique I have been
able to get working is the basic attribute-based technique such as:

<Test()> <ExpectedException(GetType(NullFieldException))> Public
Sub CanValidateEMailAddressMayNotBeNull()

_recipient = New Recipient
_recipient.EMailAddress = "Test"
_recipient.Validate()

End Sub

However I would like to be able to return a meaningful message to NUnit
such as "You must specify an EMail address" rather than just simply
working with the NullFieldException result. I have also looked at
Assert.Throws and can't seem to get this working either, though I
suspect this may be to do with limitations of VS2005.

Most of the meaningful examples that I have been able to source from the
web are using lambda expressions under c#, the converted code of which
unfortunately does not seem to work under VS2005 VB.Net.


Kind Regards

Paul Johnson
Int: 701 2561
Mob: 0770 945 3009
pa...@accipitersoftware.co.uk


************************************************************************

This e-mail is intended solely for the person or organisation to which
it is addressed. It may contain privileged and confidential information.
If you are not the intended recipient, you are prohibited from copying,
disclosing or distributing this e-mail or its contents (as it may be
unlawful for you to do so) or taking any action in reliance on it.

If you receive this e-mail by mistake, please delete it then advise the
sender immediately by reply e-mail to Paul.J...@sppowersystems.com.

Without prejudice to the above prohibition on unauthorised copying and
disclosure of this e-mail or its contents, it is your responsibility to
ensure that any onward transmission, opening or use of this message and
any attachments will not adversely affect your or the onward recipients'
systems or data. Please carry out such virus and other such checks as
you consider appropriate.

An e-mail reply to this address may be subject to monitoring for
operational reasons or lawful business practices.

This e-mail is issued by SP Power Systems Limited, company number 215841
and having its registered office at 1 Atlantic Quay, Glasgow, UK G2 8SP.
In sending this e-mail the sender cannot be deemed to have specified
authority and the contents of the e-mail will have no contractual effect
unless (in either case) it is otherwise agreed between SP Power Systems Limited and the recipient.

Yann Duran

unread,
Feb 9, 2010, 11:40:27 AM2/9/10
to nunit-...@googlegroups.com
Hi Paul,

I've been able to successfully use the following, however I'm using VS2008
with .NET 3.5, so YMMV.

For Methods Returning a Value
====================
Assert.Throws(Of InvalidOperationException)(Function()
NameOfFunctionBeingTested(arg))

For Methods Not Returning a Value
======================
Assert.Throws(GetType(InvalidOperationException), AddressOf SubBeingTested)

This may not be the actual answer for you, but it might nudge you along in
the right direction?

Yann

--------------------------------------------------
From: "Johnson, Paul (PS)" <Paul.J...@SPPowerSystems.com>
Sent: Wednesday, February 10, 2010 2:58 AM
To: <nunit-...@googlegroups.com>
Subject: [nunit-discuss] Using ExpectedExcpetion OR Assert.Throws in VB.NET

Charlie Poole

unread,
Feb 11, 2010, 5:46:49 PM2/11/10
to nunit-...@googlegroups.com
Hi Ron,

The idea of adding info to the xml output has come up before but
I don't think it's actually documented in a feature request. Yet.

Charlie

Reply all
Reply to author
Forward
0 new messages