Test classes are created as local classes in a special unit test include.
This is the basic structure of a test class:
CLASS lcl_test DEFINITION FOR TESTING DURATION SHORT RISK LEVEL HARMLESS. PRIVATE SECTION. DATA: mo_cut TYPE REF TO zcl_dummy. METHODS: setup, "********* 30 chars *********| dummy_test for testing. ENDCLASS. CLASS lcl_test IMPLEMENTATION. METHOD setup. CREATE OBJECT mo_cut. ENDMETHOD. METHOD dummy_test. cl_aunit_assert=>fail( ). ENDMETHOD. ENDCLASS.
Any method declared with
FOR TESTING will be a unit test.
setup is a special method that is executed before each test.