Search code examples
unit-testingabap

Can I use ABAP Unit tests in classic ABAP report?


I would like to implement ABAP Unit tests in my ABAP programs, but my first report is a classic ABAP report, no OO classes at all.

Is this even possible? Or ABAP Unit intended solely on OO classes?

Can I use it with subroutines?

PERFORM get_date_range using sy-date changing lv_fromdate lv_todate.

P.S. I'm a long time Java developer still learning ABAP.


Solution

  • You could very well in your test class/method use

    PERFORM <form> IN PROGRAM <prog>

    And then validate the results you get back.

    Edit:

    Furthermore, the SAP help states this :
    Creating ABAP Unit Tests
    ABAP Unit tests are implemented in the form of test methods in local test classes in ABAP programs and the expected results are checked using the static methods of the auxiliary class CL_AUNIT_ASSERT.

    Which validates the point that tests for ABAP programs should be local test classes as per some below answers. One can still use PERFORM <form> IN PROGRAM <prog> but I would venture it is a better approach to have the tests locally.

    T.