Hi,
I created a small example of testing using ABAP Unit shown below.
But i get a syntax error in German, i translated to English and this is what i get
The reference to a test class (marking with FOR TESTING) is only in test classes possible
How do i resolve this?
CLASS myclass DEFINITION.
PUBLIC SECTION.
CLASS-DATA text TYPE string.
CLASS-METHODS set_text_to_x.
ENDCLASS.
CLASS myclass IMPLEMENTATION.
METHOD set_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'
msg = 'failed').
ENDMETHOD.
ENDCLASS.
DATA my_ref TYPE REF TO mytest.
CREATE OBJECT my_ref type mytest.
call METHOD my_ref->mytest.