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

Abap Unit Test

Former Member
0 Likes
853

Hi All,

Can any one tell with some sample code how to test private method using Abap unit test.

Thanks in advance,

Mani

7 REPLIES 7
Read only

Former Member
0 Likes
791

Hi Mani,

Welcome TO SDN!

you can view some of the links below

sapgenie.com

sapfans.com

Read only

Former Member
0 Likes
791

Hi Manikandan,

All private methods methods will be calling in public methods of same class.So, Place a break point before and after the private method where it is calling.In Debugging mode you can show inputs and outputs.

For e.g.

method private_method(IS_header_dtls, IT_item_dtls )

program logic here.......

endmethod.

method public_method( )

program logic here....

<b>Place here one break point</b>

call method Zclass->private method

Exporting

IS_HDR_DTLS

IT_ITEM_DTLS

Importing

Result_flag

<b>Place here one break point</b>

Read only

Former Member
0 Likes
791

hi manikandan,

check this url:

http://help.sap.com/saphelp_nw04/helpdata/en/98/7e1440a1c32402e10000000a1550b0/frameset.htm

<i>rewards points if it helps</i>.

with regards,

Manikandan R

Message was edited by: manikandan rajendran

Read only

SnezhinaV
Product and Topic Expert
Product and Topic Expert
0 Likes
791

Hi,

You can also check this:

http://help.sap.com/saphelp_nw04/helpdata/en/98/7e1440a1c32402e10000000a1550b0/frameset.htm

But, hmmm, to the best of my knowledge ABAP Unit Test Browser is still under development...

Regards,

Snezhi

Read only

former_member183804
Active Contributor
0 Likes
791

You can achieve this by declaring the test class as local friend of the class-pool under test.

For details please refer to the ABAP online documentation.

Best Regards

Klaus

Read only

0 Likes
791

Hello Klaus,

I currently have the same problem where I want to test some private and static methods of a public class.

For that matter I have created a test class definition under 'local types' of the production class.

And I have created the class implementation under the 'Implementation' of the production class.

When trying to call the private method, I get an error message (no access to private methods).

Unfortunately I don't find the place where to put the friends statement. I'm assuming it must be put in the definition of the production class but I only find a global friends statement. I cannot put another friends statement here.

So, I think the key is to know where to create the class-pool and where the test class in relation to the production class.

Read only

0 Likes
791

Hello Michael,

as first part do not put the definition of the test class into the defintion include. Keep definition and implementation of the test class in the dedicated test class include (release 7.00 onwards) or the implementation include. Then start with following statement sequence.

Best Regards

Klaus


class lcl_Unit_Test definition deferred.
class cl_Domain_Code definition local friends lcl_Unit_Test.

class lcl_Unit_Test definition 
  for testing                                        "#AU Risk_Level Harmless
  inheriting from cl_Aunit_Assert.

  private section.