Entering content frame

This graphic is explained in the accompanying text ABAP Unit - Example Locate the document in its SAP Library structure

Definition of a test class mytest with a test method mytest that checks the value of the text attribute after the mymethod method of the class myclass has been called. In this example, the ABAP Unit test reports an error since the value "X" is expected instead of "U".

* Production classes

CLASS myclass DEFINITION.

  PUBLIC SECTION.
    CLASS-DATA text TYPE string.
    CLASS-METHODS set_text_to_x.
ENDCLASS.


CLASS myclass IMPLEMENTATION.
  METHODset_text_to_x.
    text = 'U'.

  ENDMETHOD.
ENDCLASS.

* Test classes

CLASS mytest DEFINITION FOR TESTING.

  PRIVATE SECTION.
    METHODS mytest FOR TESTING.
ENDCLASS.


CLASS mytest IMPLEMENTATION.
  METHOD mytest.
    myclass=>set_text_to_x( ).
    cl_aunit_assert=>assert_equals( act = myclass=>text
                                    exp = 'X' ).

  ENDMETHOD.
ENDCLASS.

 

 

Leaving content frame