1

While running an Nunit project with the .csproj extension through Nunit3-console, the two tests are correctly picked correctly.

nunit3-console.exe SeleniumCHash.csproj

But, when I try to filter out one of the tests by selecting the class file to be executed, the tests are not getting picked up.

nunit3-console.exe --where "class =~ 'SeleniumCHash: FirstTest'" SeleniumCHash.csproj

The following is my Class File.

namespace SeleniumCHash
{
    [TestFixture]
    public class FirstTest : TestBaseClass
    {
        [Test]
        public void LoginCheck()
        {
        }

    }
}
ItsMeGokul
  • 403
  • 1
  • 5
  • 16

1 Answers1

1

The syntax you are using suggests you have a class named "SeleniumCHash: FirstTest". Of course, that's impossible. So when no test is found, no tests are run.

You don't provide your code, but I'm guessing it's something like

namespace Some.Thing
{
    public class SeleniumCHash
    {
        [Test]
        public void FirstTest() { ... }
        ...
    }
}

You could run FirstTest using any of the options

--where "class == Some.Thing.SeleniumCHash && method == FirstTest"
--test Some.Thing.SeleinumCHash.FirstTest
--where "test == Some.Thing.SeleniumCHash.FirstTest"
--where "test =~ FirstTest"

The last one, of course, will only work if there are no other tests that match "FirstTest". If there are, then all of them will run.

Note that class and method refer to the C# elements whereas test refers to the full name of the test, which usually contain those elements but which also may be modified by the user writing the test code.

Charlie
  • 12,928
  • 1
  • 27
  • 31
  • Thanks @Charlie. But, what would be the syntax if I want to run all the tests in class file. Sorry for missing the class file structure earlier. I've added the same in the question now. – ItsMeGokul Dec 12 '18 at 12:15
  • Found it myself. **nunit3-console.exe --where "class = SeleniumCHash.FirstTest" SeleniumCHash.csproj**...Thanks for leading me in the right path. Accepting your answer. – ItsMeGokul Dec 12 '18 at 12:19