Chapter 1: X++ Unit Test Framework
Chapter 2: Working with Data
Chapter 3: Classes
Chapter 4: Forms
Chapter 5: Visual Studio Integration
Chapter 6: Workflow
Lesson 2 : Creating Test Cases
Creating Test Cases
Creating Test Cases in a unit test, in the context of the Unit Test framework, includes test cases, how test cases are staged with data, and the organization of test cases. A test case is a class that extends the SysTestCase class. You can add test methods to test each requirement of the feature code.
The following example is of how to create a test case. In this example you will be testing an existing system class, so the results should be successful. You will test the SysDictTable class, to make sure its methods to return the table name and group for a given table name, are correct. The following is the test case class declaration.
In Microsoft Dynamics AX, a unit test is code used to test code that implements feature logic. Unit tests include test cases, the set up and tear down of tests, and the organization of one or more test cases. To implement a unit test, you create a test case which is a new class that extends the SysTestCase Class class.
When you create a test case, you will create a class that must follow the naming convention best practice. Use the same name as the class that you are testing followed by Test. This will associate the test class together with the class you are testing. In this procedure, you will create a class named EmployeeTest that extends the SysTestCase class. The EmployeeTest class will test the Employee class and the Name method. For the complete steps to create the Employee class, see Walkthrough: Testing a Class Using the Unit Test Framework. The following summarizes what the code should look like in the Employee class.