ProgSky
ProgSky

Reputation: 2620

Parameterized test using nunit3-console.exe with TestCase attribute

I am trying to run nunit3 parameterized test using TestCase attribute.

My Test method looks like:

[Test]
        [TestCase("testuser")]
        public void OBA_Test(String name)
        {
            driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10000));
            driver.Navigate().GoToUrl(baseURL + somewebsite)
            // Code to test website. 
        }

Then I take the dll and try to run using

nunit3-console.exe "C:\temp\test\Selenium Testing Prod.dll" /run:"SeleniumTests.SeleniunProdTest.OBA_Test(\"testuser\")"

enter image description here

What am I doing wrong here? Any pointers ?

Ref: nunit-console does not run tests parameterized with TestCase attribute

Upvotes: 2

Views: 1754

Answers (2)

ProgSky
ProgSky

Reputation: 2620

I was using nunit version 2 which is missing some feature. I updated to version 3 and followed this article : http://executeautomation.com/blog/passing-parameters-to-nunit-test-via-cli-using-params/

essentially in my [Setup] I collected my command line input as :

name = TestContext.Parameters.Get("empname");

and used this in my [Test] and used --params in commandline as below:

nunit3-console.exe --params:empname=testemp "C:\temp\Debug_PROD\Selenium Testing Prod.dll"

Upvotes: 1

Charlie
Charlie

Reputation: 13746

The message is telling you that there is no /run option recognized by the version of NUnit you are using. The /run of NUnit V2 was replaced by the enhanced /test option in NUnit 3.

Upvotes: 3

Related Questions