Running TestLeft Tests from NUnit Tests

Applies to TestLeft 15.40, last modified on March 17, 2022

You can include TestLeft test code in unit tests and run them by using various unit testing frameworks. This topic describes how to run TestLeft tests with NUnit:


NUnit is a unit testing framework for .NET applications. TestLeft provides an NUnit project template for Visual Studio that simplifies creation of NUnit tests that run TestLeft code. You will be able to run such tests by using the NUnit utility or from Visual Studio by using NUnit Test Adapter.

  • You need to have NUnit version 3.2 installed. To learn how to install it, see the Installation section of the NUnit documentation.

  • To run TestLeft tests from Visual Studio by using NUnit Test Adapter, you must have the NUnit 3 Test Adapter extension installed in your Visual Studio. To learn how to install the adapter, see the Adapter Installation section in the NUnit documentation.

  • The NUnit project and test templates are available only for Visual Studio projects that target .NET Framework version 4.5 or higher.

Note: If you use an earlier version on NUnit or if you use another unit testing framework, you can add TestLeft code to your unit tests and run them by using your framework manually, without using the templates.
Creating and Running a TestLeft Test
  1. Add a TestLeft NUnit Test Project to your solution:

    • In Visual Studio’s Solution Explorer, right-click the solution and then click Add New Project.

    • In the Add New Project dialog, select the Test category and then select the TestLeft NUnit Project type.

      TestLeft NUnit Project Template

      Click the image to enlarge it.

    • Click OK to add a project.

    • Visual Studio will add a TestLeft NUnit Project to your solution.

      TestLeft NUnit project in Visual Studio

      Click the image to enlarge it.

  2. In the created project, add a reference to the nunit.framework.dll library:

    By using NuGet


  3. The NUnit TestLeft project includes a reference to the SmartBear.TestLeft.dll library.

    The project also defines a TestFixtureBase class. The class specifies methods to call before, after and when running a test. Use the class to create tests.

    Note: The project defines a sample test - HelloWorldTest. You can delete it if you do not need it or use it as a base to create your own tests.
  4. Write your test code. To learn how to create test instructions, see 2. Write Test Code.

  5. Build the project.

  6. Run the test:

    By using NUnit Test Adapter

    From the command line

  7. After the test run is over, Visual Studio will automatically save the test results to the folder where the test assembly resides. It will store the test results in the unpacked HTML format. Open the index.htm file to view the test log.

    Unit test results

    Click the image to enlarge it.

See Also

Running TestLeft Tests From Unit Testing Frameworks
Using TestLeft
Writing Test Code

Highlight search results