In order to be able to run your tests, You need to resolve dependencies (restore packages), build the solution/project and run the tests. (the HTML report automatically generated based on the code, you don’t need to take any actions to get the HTML report) 

Below you can find step-by-step description about how to do these actions. 

Restore NuGet Packages 

  1. Download nuget.exe 
    • In order to be able restore your packages, you’ll need the nuget.exe executable. NuGet is the C# package management solution. It is used to download, delete, restore and manage dependency packages. 
    • The list of the dependent packages can be found in the packages.config file, which is usually located in the root folder of the project or the solution.
    • You can download the latest nuget.exe file from here: 
    • You need to download the Windows x86 Commandline version (preferably the latest). 
  2. Restore nuget packages 
    • You need to open a command prompt, and change the directory to the one, you have your downloaded nuget.exe file. 
    • You can run this script from the cmd then: nuget.exe restore <projectPath> [options] 
    • For the <projectPath> you can set the path of the solution file or the packages.config file ( for example: C:\Workplace\YourTest\testsolution.sln )
    • For the [options] I advise you to set -versobity detailed, it could help if something goes wrong with the restoring process. 
    • Another option that can be set is the source which specifies from where to download the packages. It searches the nuget collection by default, but sometimes it has hard time doing it without specifying the source. 

So the command should look something like this: nuget.exe restore YourSolutionFile.sln -verbosity detailed -source 




Build your solution/project

1, Download MSBuild.exe

Run your tests

  1. Download nunit3-console.exe
    • We use NUnit as the runner for our tests. To be able to run the tests from command line, you’ll need nunit3-console.
    • You can download it from here:
    • Click on the NUnit Console 3.x link from the latest releases. It will take you to a github page. From there, download the file and extract to a folder of your choice.
  2. Run the tests with NUnit
    • Open up a command line window, change the working directory to the one where you extracted the NUnit3-console.
  3. Then you can send in your run command based of this: nunit3-console.exe [options] <testAssemblyPath>
    • You can define the reporting options in place of the options placeholder.

    • Reporting options can contain:

      • If you don’t want any report to be generated: –noresult

      • If you would like a text report to be generated: –out=<PathAndFilename> (for example: –out = MyTestResult.txt, which will generate a txt report to the root folder of the project)

      • If you would like an xml report to be generated: “–result=<PathAndFilename>;format=nunit2” (better to be generate an nunit2-like formatted xml, more xml parsers can parse it and easier to read. For example: “–result=MyXmlResult.xml;format=nunit2”)

      • You can find more options here:

For the testAssemblyPath you need to give the dll generated from the build of the project. For example: MyTestFolder\bin\Debug\MyTest.dll (the dll can be in the Debug or the Release folder in the bin, depending on how the project is built)

So if you’d like to run your tests and generate a text and also an xml report from it, the command looks something like this:

nunit3-console.exe –out=MyLandingPageTestExampleReport.txt “–result=MyTestXmlResult.xml;format=nunit2” C:\AllMyTestsFolder\MySolutionFolder\MyFavoriteTestProjectFolder\bin\Release\MyTest.dll

The test will run, and it’ll give some feedback during execution in the command prompt about the tests passing/failing, but after it ran, you’ll get a summary too. And you can also check the HTML report for the test status which can be found in the Reports folder of the project’s root directory.

Additional information

You can add nunit3-console.exe’s, nuget.exe’s and also msbuild.exe’s directory to the system path. If you do so, you won’t need to specify their path and also you’ll be able to leave off the .exe part. So you can call:

  • nuget restore [paths and options]
  • msbuild SomeSolution.sln /t:rebuild [other options]
  • nunit3-console –noresult C:\WorkSpace\MyTest\bin\Release\MyTest.dll

for example.

It is not a must do process, just optional to help your work.