Create a testing project in Visual Studio

In Visual Studio, on Windows OS, you can create NUnit or MSTest testing projects and test items using the installed templates.

Create a project

If you are creating an NUnit project, make sure that you have a supported version of the NUnit framework installed. For details on supported NUnit versions, see the Support Matrix.

Note: In NUnit 3, the NUnit Runner and the NUnit framework are installed separately. Make sure to install the NUnit framework, preferably through the NuGet package manager.

  1. Create a new project. Select Visual C# > Test project, and then either the UFT Developer NUnit or MSTest project templates.

  2. To add a test item in the project, in the Solution Explorer, right-click the project and select Add UFT Developer.

Back to top

Visual Studio template content

The NUnit/MSTest UFT Developer project templates include the following:

  • Reference to the HP.LFT.SDK and related HP.LFT.* elements (project template only)

  • Reference to Microsoft.CSharp and, for OpenText Functional Testing for Developers NUnit projects, nunit.framework (project template only)

  • App.config, which enables you to customize some test settings (project template only). For details, see Customize test settings.
  • A basic UFTDeveloperTest.cs template where you write your code (project and item templates).

    You can include multiple tests in one class, and you can use the Object Identification Center or Test Recorder to help generate the code.

    The exact structure of this template depends on whether you are using NUnit or MSTest. In both cases, they include attributes where you can define:

    Setup code Runs once at the start of the class
    Setup code Runs once at the start of each test
    Individual test units
    • The template includes a single [Test] (NUnit) / [TestMethod] (MSTest) attribute containing an empty Test() / TestMethod() method. You can rename this method to whatever you want to call your test.
    • You can add multiple [Test] / [TestMethod] attributes if you want to include several tests in your class.
    • Each [Test] / [TestMethod] attribute should declare a void test method that contains the main code for that test.
    Cleanup code Runs at the conclusion of each test
    Cleanup code Runs once at the end of the class
  • UnitTestClassBase.cs, which controls what happens during the different phases of your run, including running and closing the runtime engine (project template only).

Example: A new OpenText Functional Testing for Developers NUnit project in Visual Studio:

  • For details on using the MSTest framework, see the relevant MSDN documentation.
  • For details on using the NUnit framework, see the NUnit documentation.

Back to top

Next steps: