Explicit attribute for TestCase

349 views
Skip to first unread message

Swathi

unread,
Nov 1, 2011, 11:52:35 AM11/1/11
to NUnit-Discuss
Hi,
I have a set of 10 TestCases for a particular test.
Of those 10 testcases, I know one of them will fail till one of the
devices in the network is rectified.
So I want to mark this particular test case as Explicit. When I run
the test, all testcases are run including the one marked as Explicit.

Is there any way, to mark just one testcase so that it is run but
outputs a message that it will not succeed till the equipment is
available?

Thank you very much in advance.

Charlie Poole

unread,
Nov 1, 2011, 12:47:31 PM11/1/11
to nunit-...@googlegroups.com
Hello Swathi,

There is no way currently to mark an individual test case as explicit when
using the TestCase attribute.

I am guessing that you did something like this...
[TestCase(...)]
[TestCase(...)]
[TestCase(...), Explicit]]
[TestCase(...)]

However, that would mark method as Explicit, not the individual case. If you
run the containing test fixture, none of your test cases will run.
That's because
[TestCase(...), Explicit] is semantically equivalent to this:
[TestCase(...)]
[Explicit]

You might think we could take the position of attributes into account and apply
this to the preceding or following test case, but that's not so.
Without examining
the source, it's not possible to determine the lexical order of
attributes reliably.
When we reflect over them, the order in which they are returned varies between
different implementations - even different versions - of the runtime.

One short-term fix would be to mark the individual test case as Ignored, using
the Ignore (synonymous with Ignored) or IgnoreReason named parameter,
like this: [TestCase(..., IgnoreReason="Network problem")] This will cause the
test case to be ignored until the problem is fixed and you change the code. An
alternative, of course, is to simply comment out the test case, but then you
have to remember to uncomment it when it's ready to run again.

For NUnit 2.6, we could add an Explicit named parameter to TestCaseAttribute.
Would you file a request for this on launchpad?

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.
>
>

Swathi

unread,
Nov 3, 2011, 6:39:05 AM11/3/11
to NUnit-Discuss
I think for my issue, IgnoreReason can be a work around. Thank you.
howeevr if I use IgnoreReason, I would expect some kind of change in
the GUI. When I run the ignored Test, it is marked in yellow with a ?
which is good. But I was also expecting to see in the GUI the reason
why it was ignored. Or somekind of indication in the GUI which
clearly indicates that the particular testcase is ignore.

PS: I have filed a request in launchpad for the Explicit named
parameter.
> > For more options, visit this group athttp://groups.google.com/group/nunit-discuss?hl=en.- Hide quoted text -
>
> - Show quoted text -

vineet chauhan

unread,
Nov 3, 2011, 7:18:10 AM11/3/11
to nunit-...@googlegroups.com

Hi All,

I am looking for a moke project having test case as well,so i can test in Junit.PLease send me the information on Vineet....@hotmail.com

Many Thanks in Advance,

Cheers,
Vineet Chauhan

Swathi

unread,
Nov 3, 2011, 8:31:39 AM11/3/11
to NUnit-Discuss
After more investigation, I realised that there is a "Tests not run"
tab, where the tests that are not run are displayed and the reason is
also displayed. Thats is good enough.

On Nov 3, 11:18 am, vineet chauhan <chauhan....@gmail.com> wrote:
> Hi All,
>
> I am looking for a moke project having test case as well,so i can test in *
> Junit*.PLease send me the information on Vineet.chau...@hotmail.com

Charlie Poole

unread,
Nov 3, 2011, 11:14:29 AM11/3/11
to nunit-...@googlegroups.com
In addition, you can right-click on any test and select properties to
see info about
that test, including the ignore reason.

Charlie

Charlie Poole

unread,
Nov 3, 2011, 11:15:59 AM11/3/11
to nunit-...@googlegroups.com
JUnit? Try the JUnit list. :-)
Reply all
Reply to author
Forward
0 new messages