Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Why Assertion-Class CL_ABAP_UNIT_ASSERT is final?

majcon
SAP Champion
SAP Champion
0 Likes
475

Hi NG,

with Release NetWeaver 7.0 EhP2 SAP introduced the ABAP Unit Assertion-Class CL_ABAP_UNIT_ASSERT.

Compared with the old Assertion-Class (CL_AUNIT_ASSERT), the new class is declared as FINAL.

What is the reason behind this change?

It was really comfortable to inherit the CL_AUNIT_ASSERT class in my Test-Classes and to use the shorter-Form of the Assertion-Methods.

Any Idea, why the class is now closed for Inheritation?

Best regards,

Damir

1 ACCEPTED SOLUTION
Read only

former_member183804
Active Contributor
0 Likes
433

Hello Damir,

as you wrote it is popular to inherite from cl_Aunit_Assert to save typing. That made cl_Aunit_Assert to the class with the most child classes in the ABAP word. With that many child classes it is impossible to add a new method to cl_Aunit_Assert without the risk to break a child class. Therefore a new classes with new methods and no possibility to inherit has been introduced. Extensibility is the major reason..

Best Regards

  Klaus

2 REPLIES 2
Read only

former_member183804
Active Contributor
0 Likes
434

Hello Damir,

as you wrote it is popular to inherite from cl_Aunit_Assert to save typing. That made cl_Aunit_Assert to the class with the most child classes in the ABAP word. With that many child classes it is impossible to add a new method to cl_Aunit_Assert without the risk to break a child class. Therefore a new classes with new methods and no possibility to inherit has been introduced. Extensibility is the major reason..

Best Regards

  Klaus

Read only

0 Likes
433

Hi Klaus,

thanks for the answer.

In Perspective of Customers or Tool-Developer it`s harder to extend or use the Framework.

But, It is important to think about clean-code and clean-architecture so avoiding such God-Classes in an System seems to be a good decision...

Best Regards,

Damir