fail( )
method which has an extra detail
parameter, which will work with multiline strings. \n
line endings are needed in the detail string, because \r
ends up being displayed as #
in the test runner.quit-no
parameter, we can output multiple failures in a row to add as much diagnostic information about the failure as needed.level = if_aunit_consants=>severity-low
to your assertion.REPORT zfh.
CLASS lcl_test DEFINITION FINAL FOR TESTING
INHERITING FROM zcl_abap_unit_wrapper
DURATION SHORT
RISK LEVEL HARMLESS.
PRIVATE SECTION.
"! Method under test
METHODS is_latin
IMPORTING text TYPE string
RETURNING VALUE(result) TYPE abap_bool.
METHODS:
test_latin_knowledge FOR TESTING RAISING cx_static_check.
ENDCLASS.
CLASS lcl_test IMPLEMENTATION.
METHOD test_latin_knowledge.
DATA(text) =
|Lorem ipsum dolor sit amet, consectetur adipiscing elit. \r\n| &&
|quam. Vivamus rutrum accumsan quam id rhoncus. \r\n| &&
|Etiam blandit metus sit amet vestibulum hendrerit. \r\n| &&
|Aenean placerat auctor fringilla. Pellentesque iaculis tortor a urna facilisis, \r\n|.
assert_false(
act = is_latin( text )
msg = `Latin test failed`
quit = quit-no
level = if_aunit_constants=>severity-low ).
REPLACE ALL OCCURRENCES OF |\r| IN text WITH ||. " test runner outputs \r as #
fail( msg = `Failure. Lorem ipsum is not latin.` detail = text quit = quit-no ).
REPLACE ALL OCCURRENCES OF |lorem ipsum| IN text WITH || IGNORING CASE.
fail( msg = `This should fix it:` detail = text quit = quit-no ).
assert_false(
act = is_latin( text )
msg = `Latin test failed again.`
quit = quit-no ).
ENDMETHOD.
METHOD is_latin.
result = xsdbool( text CS `lorem ipsum` ).
ENDMETHOD.
ENDCLASS.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |