1. Create a Visual Studio Project

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

You can write test code using C# and Visual Basic .NET languages, and you can add your test code to projects of any supported type in Visual Studio.

In addition, TestLeft provides templates for creating tests in Visual Studio (for the .NET Framework). You can run projects created via these templates by using MSTest, NUnit and xUnit.net unit testing frameworks. This way, you will be able to create and run TestLeft tests using the testing framework you already use in your company.

In this tutorial, we will show how to create a test project for both .NET Framework and .NET Core. We will use the following templates:

  • The template shipped with TestLeft – the TestLeft MSTest Project template (for .NET Framework).

  • The standard template – the MSTest Project (.NET Core) template (for .NET Core).

1. Create a Project

Add a new project to an existing Visual Studio solution or create a new project.

  1. In the list of project templates, select the Test category and then select TestLeft MSTest Project and MSTest Project (.NET Core) for .NET Framework and .NET Core, respectively.

    Project templates for .NET Core are available in Microsoft Visual Studio 2017 or later.

    In the New Project dialog, make sure that the project targets .NET Framework version 4.5 or higher if you select the TestLeft MSTest Project template.

    Creating a TestLeft MSTest Project

    Click the image to enlarge it.

    If needed, specify the project name and location.

    Click OK.

  2. Visual Studio will create a new project and add it to your solution:

    TestLeft MSTest project in Solution Explorer

    Click the image to enlarge it.

2. Configure the Project

  1. To create TestLeft tests, you must have a reference to the SmartBear.TestLeft.dll library added to your Visual Studio project. The library is shipped with TestLeft and resides in the <TestLeft>\API\dotNET\ folder.

    The project for .NET Framework is based on the TestLeft MSTest project template and has the needed reference by default:

    Reference to the SmartBear.TestLeft.dll library

    Click the image to enlarge it.

    If you create a project for .NET Core, add the reference manually:

    • In the Solution Explorer, right-click the Dependencies node and select Add Reference:

      Adding the reference to the SmartBear.TestLeft.dll library

      Click the image to enlarge it.

    • In the opened Reference Manager, click Browse at the bottom-right of the manager.

    • Specify the path to the SmartBear.TestLeft.dll library:


      The SmartBear.TestLeft.dll library

      Click the image to enlarge it.

    • Click OK. The Visual Studio engine will add the library to your project.

    You can install the TestLeft NuGet package as an alternative to the SmartBear.TestLeft.dll library.

  2. The SmartBear.TestLeft.dll library declares namespaces that provide base test classes and interfaces for all the supported application technologies. In the source file where you will create your test code make those namespaces available in the file's name scope.

    In this tutorial, we will need the SmartBear.TestLeft and SmartBear.TestLeft.TestObjects namespaces. They are already available in our TestLeftTest source file:

    Namespaces required for creating tests

    Click the image to enlarge it.

    If you create a test module from scratch, or if you need other SmartBear.TestLeft namespaces in your tests, make them available manually.

  3. The project created by using the TestLeft project template has the sample HelloWorldTest test method. Let’s delete it and create a new test method from scratch.

Prev     Next

See Also

Your First Test With TestLeft - .NET and .NET Core Tutorial

Highlight search results