天天看点

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单元帮助类的两种使用方式

继续阅读