In this article I will show you how to go about running your .Net project from CLI . It is especially useful when you don't want to install Visual Studio on a machine to run the project or the NUnit tests like say in the case of a Selenium test project.
1. Download and install the .Net SDK from below (I am using 6 here)
https://dotnet.microsoft.com/en-us/download/dotnet/6.0
2. In your powershell, navigate to the .Net project dir and try to do `dotnet build` and `dotnet run` to see if the installation works
3. If you plan to use and run NUnit from the CLI as well, run the below commands from the same dir.
`dotnet add package nunit nunit.console`
4. NUnit.console exe is installed in the below path. Issue the command to add it to the env var for the session only
`$Env:PATH += ";C:\Users\UserName\.nuget\packages\nunit.consolerunner\3.15.0\tools\"`
PS - To add it permanently, add in the control panel
5. Now you should be able to run the below command to run the NUnit tests from the project.
`nunit3-console .\bin\Debug\net6.0\Tests.dll`
PS - You can play around nunit3-console options to run specific test or a set of tests
6. TestResults.xml file will be generated, which can be used to see the test run results in an online nunit results viewer like this one https://tkovacs-dev.github.io/nunit3viewer/
No comments:
Post a Comment