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:
- Test Instance for Unit Testing: To Deploy an Instance, to prepare the MYOB Acumatica instance
- Test Project and Test Class: To Create a Test Project, to create and
configure the
PhoneRepairShop_Code.Tests.csprojtest project
Step: Creating a Test Class
To create a test class for the Repair Services (RS201000) form, do the following:
- In the Solution Explorer panel of Visual Studio,
right-click the
PhoneRepairShop_Code.Testsproject, and select . - Select the Visual C# item | Class template, and type RSSVRepairServiceMaintTests.cs as the file name.
- Click Add.
- Specify the following
usingdirectives in the RSSVRepairServiceMaintTests.cs file.using Xunit; using PX.Data; using PX.Tests.Unit; using PhoneRepairShop;
- Make the
RSSVRepairServiceMaintTestsclass 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.
