Denis Koreyba
Denis Koreyba

Reputation: 3718

How to run tests under a specific folder with NUnit 3?

I have a lot of tests (classes) and they are placed to different folders. It looks like this:

enter image description here

I want to run all the tests under a specific folder including all sub-folders.

Please help me to do it using NUnit 3 console commands.

Here is a manual for this https://github.com/nunit/docs/wiki/Test-Selection-Language

The thing is: if I use: --where "test==LottoSend.com.TestCases.BackOffice" then it runs only tests under sub-folders in BackOffice folder (CMS, Packages, Raffle, etc.) but it doesn't run tests placed directly in "BackOffice" folder (such as BlackListTests.cs etc.)

Maybe I need to use another parameter for this?

Upvotes: 0

Views: 560

Answers (1)

Charlie
Charlie

Reputation: 13681

NUnit knows nothing about the location of your source code. It doesn't look need or look at source code at all, but at the compiled test assembly.

If it's running the tests in the BackOffice folder, it's because they are all defined in the namespace "LottoSend.com.TestCases.BackOffice" - not because of what folder they are in.

What namespaces are used in your subfolders? Common practice would put the code under CMS in "LottoSend.com.TestCases.BackOffice.CMS" but it's up to you how you write the code.

So your choice is to either change the namespaces to match the folders or move the code to a folder that matches the namespace.

Upvotes: 1

Related Questions