How to: Display Test Case Results

Applies To: Microsoft Dynamics AX 2012 R3, Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012

Microsoft Dynamics AX includes a framework to create, run, and analyze test cases. After you create and run a test case, you will want to view the results. Various forms exist to display details about test cases. You can also enable one or more listeners. Each listener produces unique output options to display test case results.

For information about creating and running a test case, see How to: Create a Test Case and How to: Run a Test Case.

Displaying Results

The following table describes Microsoft Dynamics AX forms that display test case results.

Form name

How to access

Description

Test jobs (Overview tab)

  1. Click Tools > Unit test > Test jobs.

  2. On the Unit test toolbar, click the Details button.

Displays date, time, author, percent of code coverage, duration that the test ran, number of records that are updated by the test, and a pass/fail status for each test.

Test jobs (General tab)

On the Test jobs form, click the General tab.

Displays details specific to an individual test including code coverage, date, time, author, and the duration that the test ran.

Test jobs (Environment tab)

On the Test jobs form, click the Environment tab.

Displays details about the computer configuration that the test ran under. This includes the build number, client mode, database details, and the operating system for the client and server.

Test

On the Test jobs form, click the Tests button.

The Overview tab displays test case code coverage, duration that the test ran, number of records that were updated by the test, and the status. Also displays the same information at the method level.

The General tab displays detail of each test regarding identification, time, and code coverage.

Comparison

On the Test form, click the Coverage button.

Displays code coverage details regarding the lines of code that were executed. Click Compare to see the differences.

Infolog

On the Test form, click the Infolog button.

Displays status information about the test case and the methods that start and finish in an Overview tab that displays all tests or the General tab that displays detail for a specific test.

Test log

On the Test form, click the Log button.

Displays the method name, log type, and the log messages.

You can select the output format to display your results by clicking one or more listeners. The available listeners include output to the database, Infolog, Message window, Print window, Progress bar, text file, and XML file. The following procedure describes how to enable one or more listeners to identify the output that you want.

To select the output format to display results

  1. Click Tools > Unit test > Parameters.

  2. In the Unit test parameters form, click the Listeners link.

  3. From the Remaining pane, click the listeners that you want to enable, and then click < to move them to the Selected pane.

    Note

    For listeners that will send output to a file, the default location is the application log directory at C:\Program Files\Microsoft Dynamics AX\60\Client\Log. To change location of the file, you must programmatically register a listener. For an example, see How to: Run a Test Case.

    This procedure described how to select the output at the unit test level. To select listeners for a test project, right-click the project and then click Settings.

If the output options provided by Microsoft Dynamics AX do not meet your needs, you can create your own listener. You might want to create your own listener if you want to log on to a different database, need a specific file format, or use a .NET object. The following procedure describes how to create a listener class by implementing the SysTestListener Interface interface.

To create an alternative output format

  1. In the AOT, right-click the Classes node and click New Class.

  2. Double-click the new class to open it in the Code Editor.

  3. Change the code to the following.

        public class AlternativeListener implements SysTestListener
         {
         }
    
  4. Add methods to provide the behavior of the alternative listener.

  5. Press F7 to compile the class.

  6. In the AOT, expand the Data Dictionary node, expand the Base Enums node, right-click the SysTestListeners enumeration, and then click New Element.

  7. Click the new element, open the Properties window, and change the name and the label to AlternativeListener.

    Note

    This causes the new listener to display on the Test parameters form.

  8. Click Tools > Unit test > Parameters.

  9. On the Unit test parameters form, click the Listeners link.

    Note

    The AlternativeListener will be listed with the Remaining listeners. You will use the new listener the same as the existing default listeners. For an example of how to use a listener, see How to: Run a Test Case.

Next, think about how to organize your tests in a meaningful way. For information, see How to: Organize Test Cases. It may be necessary to create setup and tear down logic at the test case or suite of test cases level. For more information, see How to: Create Set Up and Tear Down Logic for a Test Case.

See also

Unit Test Framework

Walkthrough: Testing a Class Using the Unit Test Framework

Announcements: New book: "Inside Microsoft Dynamics AX 2012 R3" now available. Get your copy at the MS Press Store.