Create a .NET project in Visual Studio Code

In Visual Studio Code, on Windows and Linux, you can create NUnit 3 or MSTest 2 testing projects using the installed templates.

Prerequisites

  • Internet connectivity is required when creating projects.
  • .NET 6 or later
  • We recommend that you use language-specific extensions such as C# Dev Kit, to add test project development capabilities to Visual Studio Code.

Create a project

Using the extension GUI

  1. Select the Functional Testing for Developers extension in the Activity Bar.

  2. Expand the Templates menu.

  3. Expand the .NET menu.

  4. Click the desired template type (NUnit 3 or MSTest 2).

  5. Enter a name for the new project.

  6. Select a project location. By default, Visual Studio Code suggests the user's Documents folder if there is no open workspace. Otherwise, it suggests the open workspace.

  7. Optionally, select a target .NET framework.

Using the Command Palette

  1. Open the Command Palette (Ctrl + Shift + P).

  2. Type >FTD: Create .NET Project.

  3. Select the .NET project type (NUnit 3 or MSTest 2).

  4. Enter a name for the new project.

  5. Select a project location. By default, Visual Studio Code suggests the user's Documents folder if there is no open workspace. Otherwise, it suggests the open workspace.

  6. Optionally, select a target .NET framework.

Back to top

Visual Studio Code template content

The NUnit/MSTest FTD project templates include the following:

  • Reference to the HP.LFT.SDK and related HP.LFT.* elements

  • Reference to Microsoft.CSharp and, for OpenText Functional Testing for Developers NUnit projects, nunit.framework

  • App.config, which enables you to customize some test settings. For details, see Customize test settings.
  • A basic FTDTest.cs template where you write your code.

    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:

    Attribute Description
    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.

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

NUnit 3 project structure showing project files and folders

Example: A new OpenText Functional Testing for Developers MSTest 2 project in Visual Studio Code:

MSTest 2 project structure showing project files and folders

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

Back to top

Next steps: