Test Project and Test Class: To Create a Test Class

The following activity will walk you through the process of creating a test class in the test project that you have created.

Story

Suppose that you have created and configured the PhoneRepairShop_Code.Tests test project for the extension library implemented in the PhoneRepairShop_Code.csproj project. You need to create a class for testing the Repair Services (RS201000) custom form, whose business logic is implemented in the RSSVRepairServiceMaint class.

Process Overview

In the test project, you create a test class derived from the PX.Tests.Unit.TestBase class. This class is intended for containing test methods.

System Preparation

Before you begin creating the test class, make sure that you have performed the following prerequisite activities:

  1. Test Instance for Unit Testing: To Deploy an Instance, to prepare the MYOB Acumatica instance
  2. Test Project and Test Class: To Create a Test Project, to create and configure the PhoneRepairShop_Code.Tests.csproj test project

Step: Creating a Test Class

To create a test class for the Repair Services (RS201000) form, do the following:

  1. In the Solution Explorer panel of Visual Studio, right-click the PhoneRepairShop_Code.Tests project, and select Add > New Item.
  2. Select the Visual C# item | Class template, and type RSSVRepairServiceMaintTests.cs as the file name.
  3. Click Add.
  4. Specify the following using directives in the RSSVRepairServiceMaintTests.cs file.
    using Xunit;
    using PX.Data;
    using PX.Tests.Unit;
    using PhoneRepairShop;
  5. Make the RSSVRepairServiceMaintTests class public and derived from TestBase as follows.
        public class RSSVRepairServiceMaintTests : TestBase

In this class, you will create a test method to test the logic of the RSSVRepairServiceMaint graph, as described in Test Method: To Create a Test Method Without Parameters. For more information about creating test methods, see Creating a Test Method.