Search code examples
c#selenium-webdriverjenkinsnunitnunit-console

How to execute specific test classes with Jenkins Build Step


I've got Jenkins downloaded and setup on my local machine. So far I've been able to have it sync up with my github repo, pull the code down and build successfully, and then it also runs all the tests. I do all of this using the built-in Execute Windows batch command build option.

I'm trying to limit the test execution to just be a specific class. I've tried several different --where iterations and various combinations of things I've found online but every time I do it just says that there were 0 tests executed.

Here's what my current command looks like (ignore the ugliness of the directory as I'm just testing this right now)

C:\Users\<username>\Downloads\NUnit.Console-3.16.1\bin\nunit3-console.exe "%WORKSPACE%\\tree\main\DTAF\DTAF\DTAF\bin\debug\DTAF.dll" --where "class == BaseActionsTests"

I know this is the correct location for the test class because I can navigate to it directly to see it but also if I remove the --where then it runs every test...including the tests in BaseActionsTests.


Solution

  • So I was able to figure out what I needed to do. After looking at the documentation some more I decided to try using --name just to see what would happen and low and behold it ran every test in the specified test class.

    C:\Users\<username>\Downloads\NUnit.Console-3.16.1\bin\nunit3-console.exe "%WORKSPACE%\tree\main\DTAF\DTAF\DTAF\bin\debug\DTAF.dll" --where "name == ElementActionsTests"
    

    Am I wrong in thinking the documentation is misleading regarding --class and --name? It looks like class should run the test class and name should only run a single test.