Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
Timo_John
Active Participant
During the open.sap course: Writing Testable Code for ABAP by Jürgen Heymann and Thomas Hammer  alexander.geppart and me started to improve our unit test skills.

 

On request of enno.wulff we want to share an example here:


SETUP method


1. we cut the data preparation of the SETUP method to place it into the test methods.


2. also database preparation was moved ( and placed in helperMethod - see later )


3. used a special logger to support unit testing



( open image in new tab for better view )



 

Test method


1. implemented database and local data preparation for this special test in the GIVEN part and used a helper method to do the INSERT and COMMIT etc.


2. extracted helper method to run the CUT and select results. This helper also assures that the Select is successful. ( we can reuse this method for some other tests ) For negative tests we need other coding in the test methods to assure sy-subrc = 4 as example.


3. introduced a #Macro to improve readability of assertions.


4. used the #Macro to shortly write the THEN part.
Yes, Methods could do nearly the same .... yes not debugable ... but is will debug those calls. In my opinion great blog of rdiger.plantiko2 applies here.


( open image in new tab for better view )



 

Thanks in advance for your comments an feedback

Best Timo

 
3 Comments