1. Create a Visual Studio Project

Applies to TestLeft 15.0, last modified on October 14, 2021

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. 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 create a test project based on the TestLeft MSTest Project template:

1. Create a Project

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

  1. In the New Project dialog, make sure that the project targets .NET Framework version 4.5 or higher.

    Creating a TestLeft MSTest Project

    Click the image to enlarge it.

    In the list of project templates, select the Test category and then select the TestLeft MSTest Project template.

    If needed, specify the project name and location.

    Click OK.

  2. Visual Studio will create a new TestLeft MSTest 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.

    Our project is based on the TestLeft MSTest project template and has the needed reference by default:

    Reference to the SmartBear.TestLeft.dll library

    If you create a project from scratch, add the reference manually.

  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 Tutorial

Highlight search results