How to run Nunit selected test cases through command line

3,797 views
Skip to first unread message

Udhaya Kumar

unread,
Sep 30, 2013, 8:58:04 AM9/30/13
to nunit-...@googlegroups.com
Hi All,


                 This will be more helpful to me if any idea to run Nunit selected test cases through command line.



Thanks in Advance,
Udhay

Charlie Poole

unread,
Sep 30, 2013, 4:01:15 PM9/30/13
to NUnit-Discuss
Hi Udhay,

Assuming NUnit 2.6.2...

nunit-console mytests.dll -run:My.Test.Fixture.SomeMethod

Charlie
> --
> You received this message because you are subscribed to the Google Groups
> "NUnit-Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to nunit-discus...@googlegroups.com.
> To post to this group, send email to nunit-...@googlegroups.com.
> Visit this group at http://groups.google.com/group/nunit-discuss.
> For more options, visit https://groups.google.com/groups/opt_out.

Udhaya Kumar

unread,
Oct 1, 2013, 12:13:00 AM10/1/13
to nunit-...@googlegroups.com
Hi Charlie,
                     
                        i tried to run like this. but it throws error "Unable to locate fixture Nunit.Tests.Installation"

                        C:\Program Files\NUnit 2.6\bin>nunit-console /fixture:Nunit.Tests.Installation PhoenixTestFixture.dll

                        How to mention specific testcases from testfixture also if multiple testfixture.


Thanks,
Udhay

Charlie Poole

unread,
Oct 1, 2013, 2:20:55 AM10/1/13
to NUnit-Discuss
As stated in my reply, I recommend you use the -run option, which has more
capabilities and more flexibility in use.

The -fixture option will do approximately the same thing if what you
want to do is
run all the tests in a given test fixture. Are you sure that
NUnit.Tests.Installation
is the name of a fixture fixture in your assembly?

Charlie


On Mon, Sep 30, 2013 at 9:13 PM, Udhaya Kumar

Charlie Poole

unread,
Oct 1, 2013, 2:23:50 AM10/1/13
to NUnit-Discuss
Also, I notice you are running from the NUnit directory on the C: drive.
This implies that you have copied your test assembly to that directory,
which is a very strange thing to do.

If you like to work from the command line, put the NUnit bin directory
on your path and work within the directory containing your test assembly.

Charlie

Udhaya Kumar

unread,
Oct 1, 2013, 3:11:08 AM10/1/13
to nunit-...@googlegroups.com
Hi Carlie,

                       Thanks, i will try with copying nunit bin directory to my test path. But i am unable to find the testfixture name. How to find it

Inline image 1

this is how my solution looks how to type this command line. 

Thanks,
Udhay
image.png

Tyrel Alastair Hunter

unread,
Oct 1, 2013, 3:24:44 AM10/1/13
to nunit-...@googlegroups.com
The testfixture name is the name if the class containing the test it usually will have the [testfixture] attribute above it

Sent from Mailbox for iPhone


On Tue, Oct 1, 2013 at 12:41 PM, Udhaya Kumar <udhayaso...@gmail.com> wrote:

Hi Carlie,

                       Thanks, i will try with copying nunit bin directory to my test path. But i am unable to find the testfixture name. How to find it

<image.png>

Charlie Poole

unread,
Oct 1, 2013, 3:15:39 PM10/1/13
to NUnit-Discuss
Don't copy the NUnit files to your test path~!!! Set the PATH environment variable
so that it includes the location of the NUnit files!

Charlie
image.png

Charlie Poole

unread,
Oct 1, 2013, 3:19:14 PM10/1/13
to NUnit-Discuss
Looking at the screen image, It does not seem that you have anything named "NUnit.Tests.Installation" Was that just a name you invented as an example? From the tree display, it appears that you have a fixture named "KLATencor.Phoenix.TestFixtures.Installation.Installation"

Charlie
image.png

Udhaya Kumar

unread,
Oct 3, 2013, 12:23:06 AM10/3/13
to nunit-...@googlegroups.com
Hi Charlie,

                      its working fine. i am able to select and run the cases through console

Thanks,
Udhay
image.png

Udhaya Kumar

unread,
Nov 19, 2013, 12:52:36 AM11/19/13
to nunit-...@googlegroups.com
Hi Charlie,

                               How to invoke selected Test cases alone in the nunit through cmd.

Inline image 1


For Example:

From MHRegression -> Only "Automatic_A_AlignParameterAttack"  then Automatic_B_AMHSStatus
image.png

Charlie Poole

unread,
Nov 19, 2013, 1:15:37 AM11/19/13
to nunit-...@googlegroups.com
The nunit.exe program does not have any command-line options for selecting tests to run.

Charlie
image.png

Udhaya Kumar

unread,
Nov 19, 2013, 2:43:01 AM11/19/13
to nunit-...@googlegroups.com
Hi,

           i am using like this,

D:
cd "D:\Share\Phoenix Automation\TestFramework\Automation\Phoenix Deliverables\Bin"
start nunit-console.exe PhoenixTestFixture.dll -run:KLATencor.Phoenix.TestFixtures.Installation.Installation,KLATencor.Phoenix.TestFixtures.MHRegression,KLATencor.TestAutomation

Is it possible to invoke the selected, it would be better to only run the given scenarios.

Thanks,
Udhay
image.png

Charlie Poole

unread,
Nov 19, 2013, 5:11:07 PM11/19/13
to nunit-...@googlegroups.com
Sorry, you appeared to be asking about nunit.exe, where this is not possible. It's definitely possible in nunit-console.

To specify any individual test, just give it's complete name after -run. For example:

  -run:KLATencor.Phoenix.TestFixtures.MHRegression.Automatic_A_AlignParameterAttack

Of course, as you add more tests, the command line becomes very long. You may want to look at use of -runlist, which allows you to specify a file that contains the names of the tests to run, one per line.

Charlie
image.png
Reply all
Reply to author
Forward
0 new messages