‎2006 Jan 19 5:24 AM
Hi All,
Can any one tell with some sample code how to test private method using Abap unit test.
Thanks in advance,
Mani
‎2006 Jan 19 5:26 AM
Hi Mani,
Welcome TO SDN!
you can view some of the links below
sapgenie.com
sapfans.com
‎2006 Jan 19 5:42 AM
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>
‎2006 Jan 19 6:00 AM
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
‎2006 Jan 19 8:42 AM
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
‎2006 Mar 15 6:28 PM
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
‎2007 Jun 14 8:55 AM
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.
‎2007 Jun 14 9:21 AM
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.