‎2025 Jul 22 8:34 AM - edited ‎2025 Jul 22 8:54 AM
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.
DATA: mo_tool_double TYPE REF TO zif_data_tool.
METHODS: setup
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_call( mo_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_expectations( mo_tool_double ).
ENDMETHOD.
ENDCLASS.
Request clarification before answering.
| User | Count |
|---|---|
| 15 | |
| 9 | |
| 6 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.