How to run Nunit test case using test ID?

529 views
Skip to first unread message

Jigar Patel

unread,
Feb 7, 2011, 6:30:37 AM2/7/11
to NUnit-Discuss
Hi,

Currently If I want to run the single Nunit test case than I have to
execute following command:

Example:
nunit-console.exe "MyNameSpace.dll "/
run=MyNameSpace.SampleTestCase.FirstTestCases

I want to run the Nunit test case using the test ID instead of name of
the test case. For example If I specify the test id attribute to the
NUnit test case like this :[Property("Id",123)] and then I want to run
the Nunit test case using ID like below.

nunit-console.exe "MyNameSpace.dll "/run=123 but this doesn't
work.

Can anyone please help me how to assign the unique test case ID in the
Nunit test cases and then run the same test case unsing test case ID
from the nunit console exe.

Thanks,
Jigar

Charlie Poole

unread,
Feb 7, 2011, 12:10:05 PM2/7/11
to nunit-...@googlegroups.com
Hi Jigar,

While it's true that NUnit uses a test id internally, you can't use
that ID directly
to select tests. It's incorporated in the TestName, which also includes the
full name of the test. TestName is a class in NUnit, which is analogous to
AssemblyName.

NUnit assigns TestNames to each test and returns them to the runner so
that they can then be used to select individual tests. But this is only useful
in runners that maintain info about the tests and allow multiple runs - such
as the Gui runner. The console runner, of course, only runs tests one time
and exits. The console runner has no advance knowledge of what ids
will be assigned and so can only select on the basis of the class or
method name itself.

Tests can also be run based on Categories, which are basically tags. In
NUnit 3.0, we plan to add selection by Property value, which would allow
you to do what you want.

If you can explain further why you want to do this, perhaps we can
come up with an alternate approach that would help you.

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

Jigar Patel

unread,
Feb 8, 2011, 7:30:32 AM2/8/11
to NUnit-Discuss
Hi Charlie,

Yes, If you add selection by Property value in NUnit 3.0 then it will
allow me to run the test cases from command prompt using test case
IDs.

Explanation:

It is very easy to remember IDs if they are in sequence instead of
remembering whole test case name. If we can run the multiple test case
like this /run=121,122,123,129 than it will be easy for the test
developer to run the test cases instead of specifying log name of the
method.

We must include selection by Property value in NUnit 3.0.

Thanks,
Jigar
Reply all
Reply to author
Forward
0 new messages