測試類的結構
測試類在特殊單元測試包中建立為本地類。
這是測試類的基本結構:
CLASS lcl_test DEFINITION
FOR TESTING
DURATION SHORT
RISK LEVEL HARMLESS.
PRIVATE SECTION.
DATA:
mo_cut TYPE REF TO zcl_dummy.
METHODS:
setup,
"********* 30 chars *********|
dummy_test for testing.
ENDCLASS.
CLASS lcl_test IMPLEMENTATION.
METHOD setup.
CREATE OBJECT mo_cut.
ENDMETHOD.
METHOD dummy_test.
cl_aunit_assert=>fail( ).
ENDMETHOD.
ENDCLASS.
用 FOR TESTING
宣告的任何方法都是單元測試。setup
是在每次測試之前執行的特殊方法。