1
1
CLASS ltcl_test DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT FINAL .
2
2
PRIVATE SECTION .
3
+ METHODS setup.
4
+ DATA mv_setup TYPE i .
5
+
3
6
METHODS single_method FOR TESTING RAISING cx_static_check.
4
7
5
8
METHODS failing_not_for_testing RAISING cx_static_check.
@@ -13,9 +16,23 @@ CLASS ltcl_test DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT FINAL.
13
16
14
17
METHODS failing_not_for_testing_obj RAISING cx_static_check.
15
18
METHODS single_method_fail_obj FOR TESTING RAISING cx_static_check.
19
+
20
+ METHODS check_setup RAISING cx_static_check.
21
+ METHODS single_method_check_setup FOR TESTING RAISING cx_static_check.
16
22
ENDCLASS .
17
23
18
24
CLASS ltcl_test IMPLEMENTATION .
25
+ METHOD check_setup .
26
+ * this method is used internally for testing, dont set it FOR TESTING
27
+ cl_abap_unit_assert=>assert_equals(
28
+ act = mv_setup
29
+ exp = 123 ).
30
+ ENDMETHOD .
31
+
32
+ METHOD setup .
33
+ mv_setup = 123 .
34
+ ENDMETHOD .
35
+
19
36
METHOD failing_not_for_testing .
20
37
* this method is used internally for testing, dont set it FOR TESTING
21
38
cl_abap_unit_assert=>assert_equals(
@@ -93,6 +110,29 @@ CLASS ltcl_test IMPLEMENTATION.
93
110
exp = 1 ).
94
111
ENDMETHOD .
95
112
113
+ METHOD single_method_check_setup .
114
+ DATA lt_input TYPE kernel_unit_runner=>ty_input.
115
+ DATA ls_input LIKE LINE OF lt_input.
116
+ DATA ls_result TYPE kernel_unit_runner=>ty_result.
117
+ DATA ls_list LIKE LINE OF ls_result-list.
118
+
119
+ ls_input-class_name = 'KERNEL_UNIT_RUNNER' .
120
+ ls_input-testclass_name = 'LTCL_TEST' .
121
+ ls_input-method_name = 'CHECK_SETUP' .
122
+ APPEND ls_input TO lt_input.
123
+
124
+ ls_result = kernel_unit_runner=>run( lt_input ).
125
+
126
+ cl_abap_unit_assert=>assert_equals(
127
+ act = lines ( ls_result-list )
128
+ exp = 1 ).
129
+ READ TABLE ls_result-list INDEX 1 INTO ls_list.
130
+ cl_abap_unit_assert=>assert_subrc( ).
131
+ cl_abap_unit_assert=>assert_equals(
132
+ act = ls_list-status
133
+ exp = kernel_unit_runner=>gc_status-success ).
134
+ ENDMETHOD .
135
+
96
136
METHOD single_method_fail_obj .
97
137
DATA lt_input TYPE kernel_unit_runner=>ty_input.
98
138
DATA ls_input LIKE LINE OF lt_input.
0 commit comments