<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Testing private methods: Declaring a local test friend in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/testing-private-methods-declaring-a-local-test-friend/m-p/551055#M20825</link>
    <description>&lt;P&gt;Where are you writing the code, report or class?&lt;/P&gt;
  &lt;P&gt;If report, then your class cannot be public. If it's in a class then the unit test class must be in the local test classes section, tab at the bottom of your editor if you use Eclipse, somewhere in the menu if you use SE24/80.&lt;/P&gt;
  &lt;P&gt;The all the code in your first block goes in the unit test section. The design here is that it doesn't even get compiled in a productive system, hence the strong separation.&lt;/P&gt;</description>
    <pubDate>Tue, 12 Sep 2017 21:33:00 GMT</pubDate>
    <dc:creator>pokrakam</dc:creator>
    <dc:date>2017-09-12T21:33:00Z</dc:date>
    <item>
      <title>Testing private methods: Declaring a local test friend</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/testing-private-methods-declaring-a-local-test-friend/m-p/551054#M20824</link>
      <description>&lt;P&gt;I try to test the private methods of a class and therefor I declare a local test friend following this scheme:&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;class lcl_test definition deferred.
class zcl_testee definition local friends lcl_test.
...
class lcl_test definition for testing ...
...&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;This is been discussed &lt;A href="https://wiki.scn.sap.com/wiki/display/ABAP/ABAP+Unit+Best+Practices"&gt;in this wiki article&lt;/A&gt; or &lt;A href="https://blogs.sap.com/2015/10/23/abap-news-for-750-test-seams-and-injections/"&gt;in this blog entry&lt;/A&gt;.&lt;/P&gt;
  &lt;P&gt;But all I get is the syntax error "The statement CLASS is unexpected". &lt;/P&gt;
  &lt;P&gt;What is wrong here?&lt;/P&gt;
  &lt;P&gt;My complete code:&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;CLASS lcl_test DEFINITION DEFERRED.
CLASS zcl_testee DEFINITION
 PUBLIC FINAL CREATE PUBLIC .
  PUBLIC SECTION.
  PROTECTED SECTION.
  PRIVATE SECTION.
ENDCLASS.

CLASS zcl_testee IMPLEMENTATION.
ENDCLASS.

CLASS lcl_test DEFINITION.
ENDCLASS.

CLASS lcl_test IMPLEMENTATION.
ENDCLASS.
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Sep 2017 20:02:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/testing-private-methods-declaring-a-local-test-friend/m-p/551054#M20824</guid>
      <dc:creator>Martin_Bschen</dc:creator>
      <dc:date>2017-09-12T20:02:49Z</dc:date>
    </item>
    <item>
      <title>Re: Testing private methods: Declaring a local test friend</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/testing-private-methods-declaring-a-local-test-friend/m-p/551055#M20825</link>
      <description>&lt;P&gt;Where are you writing the code, report or class?&lt;/P&gt;
  &lt;P&gt;If report, then your class cannot be public. If it's in a class then the unit test class must be in the local test classes section, tab at the bottom of your editor if you use Eclipse, somewhere in the menu if you use SE24/80.&lt;/P&gt;
  &lt;P&gt;The all the code in your first block goes in the unit test section. The design here is that it doesn't even get compiled in a productive system, hence the strong separation.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2017 21:33:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/testing-private-methods-declaring-a-local-test-friend/m-p/551055#M20825</guid>
      <dc:creator>pokrakam</dc:creator>
      <dc:date>2017-09-12T21:33:00Z</dc:date>
    </item>
    <item>
      <title>Re: Testing private methods: Declaring a local test friend</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/testing-private-methods-declaring-a-local-test-friend/m-p/551056#M20826</link>
      <description>&lt;P&gt;Take my classes of package SABAP_DEMOS_CAR_RENTAL_APPL as an example, e.g. CL_DEMO_CR_RESERVATION_CATA. Check the includes where the test classes reside and where they are declared DEFERRED and as friends (local definitions and implementations).&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 05:40:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/testing-private-methods-declaring-a-local-test-friend/m-p/551056#M20826</guid>
      <dc:creator>retired_member</dc:creator>
      <dc:date>2017-09-13T05:40:31Z</dc:date>
    </item>
    <item>
      <title>Re: Testing private methods: Declaring a local test friend</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/testing-private-methods-declaring-a-local-test-friend/m-p/551057#M20827</link>
      <description>&lt;P&gt;That solved my question. &lt;/P&gt;
  &lt;P&gt;What was missing was the following code in the "Local Types"-Include&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;CLASS lcl_test DEFINITION DEFERRED.
CLASS zcl_testee DEFINITION LOCAL FRIENDS lcl_test&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;The class zcl_testee has a second definition in the "Global Class"-Include, without the LOCAL FRIENDS keyword.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 07:42:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/testing-private-methods-declaring-a-local-test-friend/m-p/551057#M20827</guid>
      <dc:creator>Martin_Bschen</dc:creator>
      <dc:date>2017-09-13T07:42:44Z</dc:date>
    </item>
    <item>
      <title>Re: Testing private methods: Declaring a local test friend</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/testing-private-methods-declaring-a-local-test-friend/m-p/551058#M20828</link>
      <description>&lt;P&gt;Is the behavior related to the ABAP version? &lt;/P&gt;
  &lt;P&gt;I have been defining the test class(es) local friends in the "Test Classes" include(CCAU). Never got an error in ABAP 740 &amp;amp; now on 750 too!&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 11:15:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/testing-private-methods-declaring-a-local-test-friend/m-p/551058#M20828</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2017-09-13T11:15:15Z</dc:date>
    </item>
    <item>
      <title>Re: Testing private methods: Declaring a local test friend</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/testing-private-methods-declaring-a-local-test-friend/m-p/551059#M20829</link>
      <description>&lt;P&gt;Placing the two lines in CCAU works for me in 7.40, 7.50 and higher.&lt;/P&gt;
  &lt;P&gt;But it is better style to place local declarations in &lt;A href="https://help.sap.com/http.svc/rc/abapdocu_751_index_htm/7.51/en-US/index.htm?file=abenlocal_type_glob_class_guidl.htm"&gt;CCDEF/CCIMP&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 12:38:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/testing-private-methods-declaring-a-local-test-friend/m-p/551059#M20829</guid>
      <dc:creator>retired_member</dc:creator>
      <dc:date>2017-09-13T12:38:01Z</dc:date>
    </item>
    <item>
      <title>Re: Testing private methods: Declaring a local test friend</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/testing-private-methods-declaring-a-local-test-friend/m-p/551060#M20830</link>
      <description>&lt;P&gt;Thanks for the clarification! Going forward i'll stick to your recommendation.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 15:12:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/testing-private-methods-declaring-a-local-test-friend/m-p/551060#M20830</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2017-09-13T15:12:06Z</dc:date>
    </item>
    <item>
      <title>Re: Testing private methods: Declaring a local test friend</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/testing-private-methods-declaring-a-local-test-friend/m-p/551061#M20831</link>
      <description>&lt;P&gt;Thank you ! , This is really helpful , Good Referance for Unit Testing&lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2023 14:32:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/testing-private-methods-declaring-a-local-test-friend/m-p/551061#M20831</guid>
      <dc:creator>sudantha</dc:creator>
      <dc:date>2023-02-03T14:32:54Z</dc:date>
    </item>
  </channel>
</rss>

