cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ABAP unit test coverage not work for CONSTRUCTOR

bazak
Associate
Associate
0 Likes
475

There is some logic in CONSTRUTOR method of my class, So I wrote some unit test for creating instance

1. The unit tests all passed successful, no dump

2. Debugging for the UT can run into break-point of CONSTRUCTOR method.

3. Other instance method UT coverage works good.

the problem is , the UT coverage of CONSTRUTOR method always 0%, anyone met this problem?

UT code like:

CLASS ltd_test DEFINITION FOR TESTING
  DURATION SHORT
  RISK LEVEL HARMLESS
  INHERITING FROM zcl_data.
  PRIVATE SECTION.

    DATAmo_tool_double TYPE REF TO zif_data_tool.

    METHODSsetup

    METHODS: constructor_test FOR TESTING.

ENDCLASS.

CLASS ltd_test IMPLEMENTATION.

  METHOD setup.
    mo_tool_double ?= cl_abap_testdouble=>create'zif_data_tool' ).

  ENDMETHOD.

  METHOD constructor_test .
    cl_abap_testdouble=>configure_callmo_tool_double )->ignore_all_parameters)->and_expect)->is_called_once).
    mo_tool_double->get_data ).

    DATA lo_c TYPE REF TO zcl_data.

    CREATE OBJECT lo_c 
          EXPORTING io_double mo_tool_double.


    cl_abap_testdouble=>verify_expectationsmo_tool_double ).
  ENDMETHOD.

ENDCLASS.

Accepted Solutions (0)

Answers (0)