nunit-console /run don't execute parameterized test-cases (with commas in test-case name)

Bug #712444 reported by Pavlo Basiuk
18
This bug affects 2 people
Affects Status Importance Assigned to Milestone
NUnit V2
Status tracked in Trunk
2.5
Fix Released
High
Charlie Poole
Trunk
Fix Released
High
Charlie Poole

Bug Description

To reproduce:
1. Create test-fixture or test-case with 2 string-type parameters
2. Try to run any test-case from such test-fixture
3. or try to run test-case (with 2 parameters of string type)

This issue is caused by: https://code.launchpad.net/~u-launchpad-brianlow-com/nunitv2/MultiTestNames

Name of parametrized test-case is:
e.g.: Oberon.ATSelenium.TestApps.ATGTests.Lib.CheckoutSanity("iplay","Firefox").FP_AMEX("Guest")
and it contains comma in test name

command-line to run this test:
nunit-console-x86.exe Oberon.ATSelenium.TestApps.ATGTests.Lib.dll /run=Oberon.ATSelenium.TestApps.ATGTests.Lib.CheckoutSanity(\"iplay\",\"Firefox\").FP_AMEX(\"Guest\")

On same time comma is used to split different test-cases from each other in command.
Comma in test-case name is treated as delimiter between test-cases, and as a result test-case is not executed.

Reproducible on versions 2.5.6-2.5.9 (not reproducible on version lower then 2.5.6)

To fix:
 use semicolon ( ; ) as delimiter between test-cases for command line /run
File: NUnit-2.5.9.10348\src\NUnitCore\interfaces\Filters\SimpleNameFilter.cs: 39

I have fixed that locally, updating from
foreach (string name in namesToAdd.Split(','))
to
foreach (string name in namesToAdd.Split(';'))

And running it like:
nunit-console-x86.exe Oberon.ATSelenium.TestApps.ATGTests.Lib.dll /run=Oberon.ATSelenium.TestApps.ATGTests.Lib.CheckoutSanity(\"iplay\",\"Firefox\").FP_AMEX(\"Guest\");Oberon.ATSelenium.TestApps.ATGTests.Lib.CheckoutSanity(\"iplay\",\"Firefox\").FP_VISA(\"Guest\")

- is executing 2 test-cases (which is exactly what I tried to do :) )

Revision history for this message
Charlie Poole (charlie.poole) wrote : Re: [Bug 712444] [NEW] nunit-console /run don't execute parametrized test-cases (with commas in test-case name)

Good catch!

On Thu, Feb 3, 2011 at 5:14 AM, Pavlo Basiuk <email address hidden> wrote:
> Public bug reported:
>
> To reproduce:
> 1. Create test-fixture or test-case with 2 string-type parameters
> 2. Try to run any test-case from such test-fixture
> 3. or try to run test-case (with 2 parameters of string type)
>
> This issue is caused by: https://code.launchpad.net/~u-launchpad-
> brianlow-com/nunitv2/MultiTestNames
>
> Name of parametrized test-case is:
> e.g.: Oberon.ATSelenium.TestApps.ATGTests.Lib.CheckoutSanity("iplay","Firefox").FP_AMEX("Guest")
> and it contains comma in test name
>
> command-line to run this test:
> nunit-console-x86.exe Oberon.ATSelenium.TestApps.ATGTests.Lib.dll /run=Oberon.ATSelenium.TestApps.ATGTests.Lib.CheckoutSanity(\"iplay\",\"Firefox\").FP_AMEX(\"Guest\")
>
> On same time comma is used to split different test-cases from each other in command.
> Comma in test-case name is treated as delimiter between test-cases, and as a result test-case is not executed.
>
> Reproducible on versions 2.5.6-2.5.9 (not reproducible on version lower
> then 2.5.6)
>
> To fix:
>  use semicolon ( ; ) as delimiter between test-cases for command line /run
> File: NUnit-2.5.9.10348\src\NUnitCore\interfaces\Filters\SimpleNameFilter.cs: 39
>
> I have fixed that locally, updating from
> foreach (string name in namesToAdd.Split(','))
> to
> foreach (string name in namesToAdd.Split(';'))
>
> And running it like:
> nunit-console-x86.exe Oberon.ATSelenium.TestApps.ATGTests.Lib.dll /run=Oberon.ATSelenium.TestApps.ATGTests.Lib.CheckoutSanity(\"iplay\",\"Firefox\").FP_AMEX(\"Guest\");Oberon.ATSelenium.TestApps.ATGTests.Lib.CheckoutSanity(\"iplay\",\"Firefox\").FP_VISA(\"Guest\")
>
> - is executing 2 test-cases (which is exactly what I tried to do :) )
>
> ** Affects: nunitv2
>     Importance: Undecided
>         Status: New
>
> --
> You received this bug notification because you are a member of NUnit
> Developers, which is subscribed to NUnit V2.
> https://bugs.launchpad.net/bugs/712444
>
> Title:
>  nunit-console /run don't execute parametrized test-cases (with commas
>  in test-case name)
>

Revision history for this message
Charlie Poole (charlie.poole) wrote : Re: nunit-console /run don't execute parametrized test-cases (with commas in test-case name)

What seems to be needed is a pattern match that ignores commas inside parentheses and also strings. Since a duplicate bug has been filed, I'll try to get it into the next release.

BTW, the ability to run single test cases for a parameterized method was never a planned feature. However, various folks have discovered it so we will try to make it work.

Changed in nunitv2:
status: New → Triaged
importance: Undecided → Medium
Changed in nunitv2:
assignee: nobody → Charlie Poole (charlie.poole)
importance: Medium → High
Changed in nunitv2:
milestone: none → 2.5.10
summary: - nunit-console /run don't execute parametrized test-cases (with commas in
- test-case name)
+ nunit-console /run don't execute parameterized test-cases (with commas
+ in test-case name)
Revision history for this message
kishore (kishore-d514) wrote :

i am having the same issue.

My Code:
namespace ClassLibrary2
{
    [TestFixture]
    public class Class1
    {
        [Test]
        public void Test1(string browser)
        {
            MessageBox.Show(Browser );
        }

    }
}

My command line execution:
C:\Documents and Settings\>"C:\Program Files\NUnit 2.6.2\bin\nunit-console" "D:\Automation\ClassLibrary2\bin\Debug\ClassLibrary2.dll /run:ClassLibrary2.Class1.Test1(\"Firefox\")

Result:
Tests run: 0, Errors: 0, Failures: 0, Inconclusive: 0, Time: 0 seconds

if i modified my code as
namespace ClassLibrary2
{
    [TestFixture]
    [TestCase("firefox")]
    public class Class1
    {
        [Test]
        public void Test1(string browser)
        {
            MessageBox.Show(Browser );
        }

    }

}

its working fine and my test is executing, because, its but this wrong bc params frm TestCase not from commandline.

C:\Documents and Settings\>"C:\Program Files\NUnit 2.6.2\bin\nunit-console" "D:\Automation\ClassLibrary2\bin\Debug\ClassLibrary2.dll /run:ClassLibrary2.Class1.Test1(\"Chrome\")

i should get Chrome .

Please give me the solution .

Thansk in advance.

Revision history for this message
kishore (kishore-d514) wrote :

I am having 1 more issue:

Sub:run specific Tests through coding

I am using Selenium with C# fro Automation, and i want to invoke the Nunit through coding, i did it using below code.

CoreExtensions.Host.InitializeService();
   TestPackage testPackage = new TestPackage(@"D:\Automation\bin\Debug\Test.dll");
   RemoteTestRunner remoteTestRunner = new RemoteTestRunner();
   remoteTestRunner.Load(testPackage);
   //TestFilter filter = new NameFilter(new TestName() { Name = "Test1" });
   TestResult testResult = remoteTestRunner.Run(new NullListener(), TestFilter.Empty, false, LoggingThreshold.Off);

and i am able to run tests using category filter as below

remoteTestRunner.Run(new NullListener(),newCategoryFilter("MyCat"),false,LoggingThreshold.Off);

But i want to execute selected tests i.e how to set suite filter, i have tried this but faild.

TestFilter filter=new NameFilter(new TestName() { Name = "Test1" });
TestResult testResult=remoteTestRunner.Run(new NullListener(), filter,false,LoggingThreshold.Off)`;

Please tell
1. how to run specific tests and
2.how to pass arguments through coding.

Thanks,
kishore.

Revision history for this message
Charlie Poole (charlie.poole) wrote : Re: [Bug 712444] Re: nunit-console /run don't execute parameterized test-cases (with commas in test-case name)

Actually not the same bug at all. This bug was fixed a long time ago.
Please don't add new problems to old bugs as it makes tracking very
difficult.

In your case, there is no bug. You have misunderstood what the /run option
does. I suggest bringing it up on the NUnit-Discuss list.
On Apr 27, 2013 12:30 PM, "kishore" <email address hidden> wrote:

> i am having the same issue.
>
> My Code:
> namespace ClassLibrary2
> {
> [TestFixture]
> public class Class1
> {
> [Test]
> public void Test1(string browser)
> {
> MessageBox.Show(Browser );
> }
>
> }
> }
>
> My command line execution:
> C:\Documents and Settings\>"C:\Program Files\NUnit
> 2.6.2\bin\nunit-console"
> "D:\Automation\ClassLibrary2\bin\Debug\ClassLibrary2.dll
> /run:ClassLibrary2.Class1.Test1(\"Firefox\")
>
> Result:
> Tests run: 0, Errors: 0, Failures: 0, Inconclusive: 0, Time: 0 seconds
>
>
> if i modified my code as
> namespace ClassLibrary2
> {
> [TestFixture]
> [TestCase("firefox")]
> public class Class1
> {
> [Test]
> public void Test1(string browser)
> {
> MessageBox.Show(Browser );
> }
>
> }
>
> }
>
> its working fine and my test is executing, because, its but this wrong
> bc params frm TestCase not from commandline.
>
> C:\Documents and Settings\>"C:\Program Files\NUnit 2.6.2\bin\nunit-
> console" "D:\Automation\ClassLibrary2\bin\Debug\ClassLibrary2.dll
> /run:ClassLibrary2.Class1.Test1(\"Chrome\")
>
> i should get Chrome .
>
> Please give me the solution .
>
> Thansk in advance.
>
> --
> You received this bug notification because you are a bug assignee.
> https://bugs.launchpad.net/bugs/712444
>
> Title:
> nunit-console /run don't execute parameterized test-cases (with commas
> in test-case name)
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/nunitv2/+bug/712444/+subscriptions
>

Revision history for this message
Charlie Poole (charlie.poole) wrote :

Re second issue: bug tracker is not the place to ask how to use nun it.
Please use the mail list.
On Apr 27, 2013 12:30 PM, "kishore" <email address hidden> wrote:

> I am having 1 more issue:
>
> Sub:run specific Tests through coding
>
> I am using Selenium with C# fro Automation, and i want to invoke the
> Nunit through coding, i did it using below code.
>
> CoreExtensions.Host.InitializeService();
> TestPackage testPackage = new
> TestPackage(@"D:\Automation\bin\Debug\Test.dll");
> RemoteTestRunner remoteTestRunner = new RemoteTestRunner();
> remoteTestRunner.Load(testPackage);
> //TestFilter filter = new NameFilter(new TestName() { Name = "Test1" });
> TestResult testResult = remoteTestRunner.Run(new NullListener(),
> TestFilter.Empty, false, LoggingThreshold.Off);
>
> and i am able to run tests using category filter as below
>
> remoteTestRunner.Run(new
> NullListener(),newCategoryFilter("MyCat"),false,LoggingThreshold.Off);
>
> But i want to execute selected tests i.e how to set suite filter, i have
> tried this but faild.
>
> TestFilter filter=new NameFilter(new TestName() { Name = "Test1" });
> TestResult testResult=remoteTestRunner.Run(new NullListener(),
> filter,false,LoggingThreshold.Off)`;
>
> Please tell
> 1. how to run specific tests and
> 2.how to pass arguments through coding.
>
> Thanks,
> kishore.
>
> --
> You received this bug notification because you are a bug assignee.
> https://bugs.launchpad.net/bugs/712444
>
> Title:
> nunit-console /run don't execute parameterized test-cases (with commas
> in test-case name)
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/nunitv2/+bug/712444/+subscriptions
>

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.