
Use the ABAP Unit wizard to generate a local ABAP class for unit testing.
Note the following about the wizard:
It is usable only with ABAP class pools and function groups. For other types of programs (such as reports) you must create the local ABAP Unit test class by hand.
It generates a basic local test class. You will still need to provide for any fixture setup and teardown, adjust the calls to your methods, and adjust the assert conditions in the test methods.
You can call the wizard repeatedly to add unit test methods for newly added class-pool methods. See also ABAP Unit - Hinweise zur Verwendung.
To use the ABAP Unit wizard, do the following:
In transaction SE80, put the cursor on the name of your class pool or function group in the Repository Browser.
Display the context menu and select for an ABAP class, or for an ABAP function group.
On the Class Selection screen of the wizard, indicate whether the test class is for the global or for a local ABAP class.
On the Test Class Selection & Options screen, click the Create icon to enter a name for the test class, for example LCL_UNIT_TEST..
Then choose the options for generating the test class.
|
Option |
Effect |
|
Generate Fixture |
Generates setup and teardown methods that are called at the start and end of each test method. |
|
Generate Class Fixture |
Generates setup and teardown methods that are called once, when the class is called and when test execution ends. |
|
Generate Invocation. |
Generates a call to each tested method in the respective test method. |
|
Generate 'Assert Equal' |
Generates a call to CL_ABAP_UNIT_ASSERT->ASSERT_EQUALS for each EXPORTING or RETURN parameter of a tested class. |
|
Duration Type |
Specifies how long the test may run without generating an error. Recommended: SHORT. |
|
Risk Level |
Specifies whether running the test is potentially dangerous (changes to the system not removed if the test aborts, and so on). |
|
Specifies the name of a class from which this test class inherits. Example: If you have defined a class that provides reusable test logic to your test class, you can specify the name of this super class in this field. |
Select the class methods for which unit test methods are to be created. You are done, and the wizard will create or extend the test class.