Microsoft Dynamics AX 2012 R3 Development-3 Locus IT Services

Microsoft Dynamics AX 2012 R3 Development-3

Locus IT ServicesMicrosoft Dynamics AX 2012 R3 Development-3

Lesson 3 : Adding Methods to Test Cases

Adding Methods to Test Cases

The next step in creating a test case, is to add some methods to the test case class. Each method should assert that one of the known requirements is true.

There are two new methods added in the following example: one to assert that the table’s name is as expected, and the other to assert that the table’s group value is as expected.

Microsoft Dynamics AX includes a framework for creating, running, and analyzing unit tests. In this walkthrough, you will create an Employee class that satisfies specific requirements. You will also create a test case that verifies that the requirements for the class have been met. The Unit Test framework is based on the principles of Test-Driven Development (TDD). For more information about TDD, see Guidelines for Test-Driven Development. TDD advises that you have a failing test case and then write the feature code to satisfy the requirement that enables the test case to pass. The following steps mention the TDD process but the goal is to emphasize the Unit Test framework. After you create and run the test case, you will view the code coverage and set the isolation level for the test case.

The requirements for the Employee class include the following:

  • When an instance of an Employee class is created, the name is set using the name method.
  • The Employee class has a retire method that is called when the employee retires. The method can only be called one time per employee.

This walk through illustrates the following tasks:

  • Creating an Employee class stub.
  • Creating a test class.
  • Setting up data for test cases.
  • Adding a test case for the name requirement.
  • Running a test case.
  • Adding a test case for the retire requirement.
  • Capturing code coverage.
  • Setting the isolation level.
Locus IT Project Management Office
What’s it?