天天看點

ABAP單元幫助類的兩種使用方式

來自我的同僚Mervin

Two way to do the unit test:

1. Using test class

Create a Test class in my local object in AG3/001

ABAP單元幫助類的兩種使用方式

chose the Test Class.

When you click OK. the Class will be generated automatically.

ABAP單元幫助類的兩種使用方式

Define My test method.

ABAP單元幫助類的兩種使用方式

Implement the method.

ABAP單元幫助類的兩種使用方式

2. Using Local test class

Copy the product class cl_crm_uiu_prod_cust_get to my local class ZCL_CRM_UIU_PROD_CUST_GET.

ABAP單元幫助類的兩種使用方式

Generate the local test class for class ZCL_CRM_UIU_PROD_CUST_GET.

ABAP單元幫助類的兩種使用方式

And chose the method you need to do the unit test. In this example, I chose the method get_Values_For_Field. The unit test method will be generated like below:

ABAP單元幫助類的兩種使用方式

Note: When you active the local class, there is error about the include. Just ignore it And active.

Implement the method get_Values_For_Field in local class.

ABAP單元幫助類的兩種使用方式

繼續閱讀