Test Framework Configuration
- 2 minutes to read
CodeRush includes the necessary assemblies to run unit tests. If you use a specific framework version, use your library to run tests. If you have a testing framework in your project, refer to the Use Integrated Framework section. Otherwise, follow the instructions in the Install a Testing Framework section.
Install a Testing Framework
Follow the steps below to download and reference the testing framework.
Select the Tools | NuGet Package Manager | Package Manager Console in Visual Studio’s menu to open the NuGet Package Manager console.
Choose the project you want to test in the “Default project“ drop-down menu.
Enter one of the following commands depending on the testing framework you want to use:
Press the Enter key and wait until all the packages are downloaded and added to the project.
Check to ensure that the NuGet package manager output does not contain errors.
After referencing a testing framework, you can create unit tests.
If the solution contains one or more unit tests, you can use the Unit Test Runner to run them. Refer to the following article for more information about the test runner: Running and Debugging Tests.
Use Integrated Framework
CodeRush includes versions of the most common testing frameworks:
NUnit
- 2.4
- 2.5
- 2.5.9
- 3.0
- 3.4
- 3.11
xUnit
- 1.9
- 2.0
- 2.1
If you use one of these versions in your project, you can run unit tests without configuration. Otherwise, refer to the Reuse Existing Framework section.
Unit Test Runner also supports .NET Core test cases and Microsoft Fakes isolation framework.
Reuse Existing Framework
You can use the existing unit testing framework library to run tests in the Unit Test Runner. Follow the steps below:
1) Configure the paths to libraries on the Unit Testing | Test Runner options page.
2) In the Supported frameworks section, choose the framework to see the supported libraries for running tests.
3) Click the ellipsis button at the right of a path to a library to change the library reference.