Search code examples
nunitnunit-console

Nunit-console runner not running any tests


So I am trying to run a powershell script that is triggered by TeamCity to run specific unit tests based on the names of the files that were changed on each github commit.

Here is how I am running it from the command line:

C:\MyFolder\bin\NUnit.ConsoleRunner.3.4.1\tools\nunit3-console.exe "C:\MyFolder\Bin\UnitTesting.dll" --test="MyFolder.QuickTests.DaoTests.ProductDaoTests.ProductBasicTest"

But I keep getting this, it runs it just never runs any tests:

NUnit Console Runner 3.4.1 
Copyright (C) 2016 Charlie Poole

Runtime Environment
   OS Version: Microsoft Windows NT 10.0.14393.0
  CLR Version: 4.0.30319.42000

Test Files
    MyFolder\Bin\UnitTesting.dll

Test Filters
    Test: MyFolder.QuickTests.DaoTests.ProductDaoTests.ProductBasicTest


Run Settings
    WorkDirectory: C:\Users\Me
    ImageRuntimeVersion: 4.0.30319
    ImageTargetFrameworkName: .NETFramework,Version=v4.0
    ImageRequiresX86: False
    ImageRequiresDefaultAppDomainAssemblyResolver: False
    NumberOfTestWorkers: 2

Test Run Summary
  Overall result: Passed
  Test Count: 0, Passed: 0, Failed: 0, Inconclusive: 0, Skipped: 0
  Start time: 2016-10-17 20:28:43Z
    End time: 2016-10-17 20:28:43Z
    Duration: 0.303 seconds

Results (nunit3) saved as TestResult.xml

Now when I run it without the --test command like this:

C:\MyFolder\bin\NUnit.ConsoleRunner.3.4.1\tools\nunit3-console.exe "C:\MyFolder\Bin\UnitTesting.dll"

It runs every unit-test that we have, but I don't want to run them all, I want to run specific quick ones, and only run the large ones when we go to staging/production servers so our developers don't have to wait 15 to 20 minutes every time they commit something.

Some additional info: -My namespace that I am using for this is

MyFolder.QuickTests.DaoTests.ProductDaoTests

The Class I am calling is:

ProductBasicTest

Some of the names like the folder directories were changed because they are %teamcity% placeholders for file directories.

What am I doing wrong to not be able to run specific tests?

For some reason my nunit-console is not recognizing the /run command or /fixture or --test=.

EDIT:

I upgraded to 3.5.0 and am still getting the same issues, I am not able to use --test.

C:\MyFolder\bin\NUnit.ConsoleRunner.3.5.0\tools\nunit3-console.exe "C:\MyFolder\Bin\UnitTesting.dll" --test="MyFolder.QuickTests.DaoTests.ProductDaoTests.ProductBasicTest" 

That is the new location, and getting the same issue.

When I do --where for MyFolder it crashes Powershell but doesn't actually run anything.

When I do --explore it does the same as --where for MyFolder and does nothing for MyFolder.QuickTests .

EDIT EDIT:

Thanks to Rob I found the docs here and looked at the --where function with --where "name=ProductBasicTest" which will run all the files in that Test-Suite!


Solution

  • So thanks to Rob one of the issues that I was running into, is it was not recognizing my namespace correctly with QuickTests. So whenever I ran the function it was not running correctly.

    To fix this you can go to the Test xml file output and see what names it was running tests under.

    To run these individually you can run it by the name with the command:

    "nunit3-console.exe C:\PathToDll.dll --where "name = NameOfTest"