How to invoke Nunit Selenium C# test framework test case from Console Application?

Hi All,

Greetings. In one of my project requirement we have a Automated Testing Framework created in Selenium C# which also uses NUnit Testing. Now as per my client’s requirement they have non-technical team and cannot use Visual Studio every time to invoke and execute test case. Instead they need a console application or equivalent approach so that the Test cases can be invoked from a Console app call or by executing an .exe file. As I’m a very new to Automation Testing, not able to find right approach and solution. Seeking guidance / support, if anybody can guide for same. Thanks in advance.

Best Regards

Hey @jaindhiraj786 You do not need Visual Studio to run a VS project. You just need to have dotnet CLI on the target machine (from where you are planning to run the NUnit tests). It is important to note that the command to run the entire solution is agnostic of the Test Framework being used (i.e. same command can be used to run NUnit, XUnit, and MsTest tests).

As mentioned in the official MS documentation, you just need to trigger the following command on the terminal (or command prompt):

**dotnet test <project or solution name>**

For example - If the solution name is NUnitTestProject.sln and project name is NUnitTestProject.csproj, you can run the NUnit tests in it by triggering either of the following commands on the terminal:

**dotnet test NUnitTestProject.sln** or **dotnet test NUnitTestProject.csproj**

You can run the command dotnet --version to check the version of .NET installed on your machine.

Here is a sample execution where I am running NUnit tests located in my sample project (PS: The end result mentions that all the 4 tests have passed):

Here are some of the links you might find useful for running Selenium C# NUnit tests from the command line:

  1. Official Documentation of dotnet test command
  2. Official documentation of VSTest.Console.exe - another option to run Selenium C# tests from the command line

However, I prefer Option(1) [i.e. *dotnet test*] since it works seamlessly on Windows as well as macOS.

Do check out Selenium C# blogs on LambdaTest, as they might come handy in your Selenium C# journey!!

Hope this clarifies your doubts :slight_smile: