Question

I am writing some Abap Unit tests. It's a simple date comparison test. But I get this error about inconsistent test instrumentation.

I thought maybe it was because I was calling a SAP function module DATE_TO_DAY inside the actual class method I'm trying to test. However, when I comment out all the code and leave just empty test methods, I still get the error.

I get two errors: 1) Inconsistent test instrumentation( test class LCL_COBRA_ELIG_TEST) 2) No excecution as actual risk is too high.

Here's my test class:

    CLASS lcl_cobra_elig_test DEFINITION FINAL FOR TESTING
                               "#AU risk_level harmless
                               "#AU duration short
                              .
    PRIVATE SECTION.
      CONSTANTS: from_date_invalid(20) TYPE c VALUE 'From-Date incorrect.',
                 to_date_invalid(20) TYPE c VALUE 'To-Date incorrect.'.

    DATA: subject TYPE REF TO lcl_report_range,
          date TYPE datum.

    METHODS:
      setup,
      test_from_date_when_mon FOR TESTING,
      teardown.
    Endclass.

    CLASS lcl_cobra_elig_test IMPLEMENTATION.
      METHOD  setup.
      ENDMETHOD.                    "teardown
      METHOD  teardown.
        CLEAR subject.
      ENDMETHOD.                    "teardown
      METHOD test_from_date_when_mon.
*       CREATE OBJECT subject
*         EXPORTING
*           im_date = '20121001'.
*       date = subject->get_from_date( ).
*       CALL METHOD cl_aunit_assert=>assert_equals
*         EXPORTING
*           act = date
*           exp = '20120929'
*           msg = from_date_invalid.
     ENDMETHOD.                    "test_from_date_when_mon

   ENDCLASS. 
Was it helpful?

Solution

Take a look at the documentation:

In systems with release < 7.00 enhancement pack 2 you specify the test properties of local test classes using pseudo comments. Add the pseudo comments after the CLASS ... FOR TESTING statement. The pseudo comments have the following syntax:

SYNTAX CLASS ... FOR TESTING "#AU
Risk_Level Critical|Dangerous|Harmless "#AU Duration  
Short|Medium|Long 

You can specify one pseudo comment for each program row. To specify two test attributes for a test class, you must spread the CLASS statement across at least two lines. The field is case-sensitive.

Fixing the case issue should get rid of the instrumentation problem. The function module doesn't have any influence on this.

As for the risk level problem, that might be fixed with the case issue as well. (The docs don't state what the default risk level is.) If it isn't, reread the definition of the risk levels, set the correct risk level and then use SAUNIT_CLIENT_SETUP to allow the tests to be executed.

OTHER TIPS

I took a guess and thought maybe the attributes "Risk_Level" and "Duration" were case-sensitive since they were technically comments. That fixed my problem--fixing the case to #AU Risk_Level Harmless and #AU Duration Short.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top