Académique Documents
Professionnel Documents
Culture Documents
Prefer functional over procedural Write testable code Methods: Method body
language constructs There are no tricks to writing tests, there are only Do one thing, do it well, do it only
E.g. index += 1 or index = index + 1 tricks to writing testable code. (Google)
Instead of ADD 1 to index Descend one level of abstraction
Enable others to mock you do_something_high_level ( ).
CLASS my_super_object DEFINITION. DATA(low_level_op) = |a { b }|.
Comments INTERFACES you_can_mock_this.
Express yourself in code, not in Keep methods small
Readability rules 3-5 statements, one page, 1000 lines
comments given_some_data( ).
do_the_good_thing( ).
Delete code instead of commenting it and_assert_that_it_worked( ). Methods: Parameter number
Aim for few IMPORTING parameters, at
Formatting Test classes best less than three
Be consistent Call local test classes by their purpose METHODS a IMPORTING b c d e
CLASS unit_tests
Optimize for reading, not for writing CLASS tests_for_the_class_under_test Split methods instead of adding
Constants OPTIONAL parameters
Code under test METHODS a IMPORTING b
Use constants instead of magic Test interfaces, not classes METHODS c IMPORTING d
METHODS x
numbers DATA cut TYPE REF TO some_interface IMPORTING b
E.g. typekind_date instead of 'D' DATA cut TYPE REF TO some_class D