<?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: Coverage analyzer counts ENDLOOP as instruction: Bug or feature? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/coverage-analyzer-counts-endloop-as-instruction-bug-or-feature/m-p/9261020#M1721814</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes you are right, I missed importance of where condition in your case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In general I am not fan of exiting loops by return statements instead of condition failure. But LOOP AT is not same as WHILE statement and your example seems to be the the fastest solution for purpose that you need.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For comparison I checked what is behavior for WHILE and IF statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;100 % coverage for IF - 3 statements &lt;/LI&gt;&lt;/UL&gt;&lt;P&gt; &lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/jiveimages/191664" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;75% coverage for DO - 4 statements, 3 covered&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/jiveimages/191663" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So it is strange that there is a different way of coverage measurements:&lt;/P&gt;&lt;P&gt;- ENDIF is not counted at all to coverage.&lt;/P&gt;&lt;P&gt;- ENDDO or ENDLOOP is counted to coverage as not covered.&lt;/P&gt;&lt;P&gt;- ENDMETHOD is counted to coverage as covered line (but METHOD is not counted).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Because it is not consistent, I agree with you finally that ENDLOOP from your example must not be counted as uncovered line. Ending part of statement should be always counted as covered line or not counted at all as in case of ENDIF - common convention should be kept.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Adam&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 04 Mar 2013 12:21:54 GMT</pubDate>
    <dc:creator>adam_krawczyk1</dc:creator>
    <dc:date>2013-03-04T12:21:54Z</dc:date>
    <item>
      <title>Coverage analyzer counts ENDLOOP as instruction: Bug or feature?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/coverage-analyzer-counts-endloop-as-instruction-bug-or-feature/m-p/9261017#M1721811</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in ABAP, it is a common idiom to use a loop with where condition only for searching for a certain entry. In the table body, you either exit and evaluate the SY-SUBRC after the loop, or you set a return value and leave the modularization unit with RETURN.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem: &lt;STRONG&gt;I don't have a chance with any test whatever to reach a statement coverage of 100% for such a form routine. &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To illustrate: Consider the routine HAS_A:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;SPAN class="L0S52"&gt;form has_a &lt;SPAN class="L0S52"&gt;using &lt;/SPAN&gt;it_data &lt;SPAN class="L0S52"&gt;type &lt;/SPAN&gt;stringtab&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="L0S52"&gt;changing &lt;/SPAN&gt;ev_has_a &lt;SPAN class="L0S52"&gt;type &lt;/SPAN&gt;flag&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp; clear ev_has_a.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;SPAN class="L0S52"&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="L0S52"&gt;loop &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;at &lt;/SPAN&gt;it_data &lt;SPAN class="L0S52"&gt;transporting &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;no &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;fields&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="L0S52"&gt;where &lt;/SPAN&gt;table_line &lt;SPAN class="L0S52"&gt;ca &lt;/SPAN&gt;&lt;SPAN class="L0S33"&gt;'a'&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ev_has_a &lt;SPAN class="L0S55"&gt;= &lt;/SPAN&gt;&lt;SPAN class="L0S33"&gt;'X'&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="L0S52"&gt;return&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="L0S52"&gt;endloop&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;BR /&gt; &lt;SPAN class="L0S52"&gt;endform&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="L0S31"&gt;"has_a&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now consider the following test calls: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;SPAN class="L0S52"&gt;data&lt;SPAN class="L0S55"&gt;: &lt;/SPAN&gt;gt_data &lt;SPAN class="L0S52"&gt;type &lt;/SPAN&gt;stringtab&lt;SPAN class="L0S55"&gt;,&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gv_has_a &lt;SPAN class="L0S52"&gt;type &lt;/SPAN&gt;flag&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;BR /&gt; &lt;SPAN class="L0S31"&gt;* With empty table&lt;/SPAN&gt;&lt;BR /&gt; &lt;SPAN class="L0S52"&gt;perform &lt;/SPAN&gt;has_a &lt;SPAN class="L0S52"&gt;using &lt;/SPAN&gt;gt_data &lt;SPAN class="L0S52"&gt;changing &lt;/SPAN&gt;gv_has_a&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;BR /&gt; &lt;SPAN class="L0S31"&gt;* With unsatisfied WHERE condition&lt;/SPAN&gt;&lt;BR /&gt; &lt;SPAN class="L0S52"&gt;append &lt;/SPAN&gt;&lt;SPAN class="L0S33"&gt;'x' &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;to &lt;/SPAN&gt;gt_data&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;BR /&gt; &lt;SPAN class="L0S52"&gt;perform &lt;/SPAN&gt;has_a &lt;SPAN class="L0S52"&gt;using &lt;/SPAN&gt;gt_data &lt;SPAN class="L0S52"&gt;changing &lt;/SPAN&gt;gv_has_a&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;BR /&gt; &lt;SPAN class="L0S31"&gt;* With satisfied WHERE condition&lt;/SPAN&gt;&lt;BR /&gt; &lt;SPAN class="L0S52"&gt;append &lt;/SPAN&gt;&lt;SPAN class="L0S33"&gt;'a' &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;to &lt;/SPAN&gt;gt_data&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;BR /&gt; &lt;SPAN class="L0S52"&gt;perform &lt;/SPAN&gt;has_a &lt;SPAN class="L0S52"&gt;using &lt;/SPAN&gt;gt_data &lt;SPAN class="L0S52"&gt;changing &lt;/SPAN&gt;gv_has_a&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think, every "equivalence class" of test cases for the subroutine has been adressed with these three calls. But the coverage analyzer gives a statement coverage of 80% instead of 100%, since it counts the &lt;EM&gt;endloop &lt;/EM&gt;as statement. Also, graphically (see attachment), the ENDLOOP is marked as non-covered statement. Any idea how to cover it? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It sounds reasonable to count ENDLOOP as statement. But actually it isn't. ENDLOOP is not an executable statement. It only marks the end of a group of statements to be executed iteratively. It is a non-executable statement like DATA and should be ignored in the coverage analyzer the same way as DATA is ignored. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is counting ENDLOOP as executable statement considered a bug or a feature by SAP?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If it is a bug and is already corrected: This test was performed on a SAPKB70211 system with kernel release 720, patch level 220. Not that old...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Mar 2013 09:46:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/coverage-analyzer-counts-endloop-as-instruction-bug-or-feature/m-p/9261017#M1721811</guid>
      <dc:creator>Ruediger_Plantiko</dc:creator>
      <dc:date>2013-03-04T09:46:38Z</dc:date>
    </item>
    <item>
      <title>Re: Coverage analyzer counts ENDLOOP as instruction: Bug or feature?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/coverage-analyzer-counts-endloop-as-instruction-bug-or-feature/m-p/9261018#M1721812</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;SPAN class="j-post-author"&gt;&lt;STRONG&gt;&lt;A _jive_internal="true" class="jiveTT-hover-user jive-username-link" href="https://answers.sap.com/people/rdiger.plantiko2" id="jive-31013618067274914480996"&gt;Rüdiger&lt;/A&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do not think that there is a bug here. I think that this loop statement is not properly designed. You designed loop that always returns after first found result and you never reach code below return and ENDLOOP statement as well. Try to add some more lines below&amp;nbsp; return, then you will see why coverage does not show 100%. If you need only single row value I would recommend to use READ TABLE better.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The code coverage is not missing only ENDLOOP statement here, but it shows that any commands that are after RETURN will never be covered. So actually it is a good indicator.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Adam&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Mar 2013 10:53:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/coverage-analyzer-counts-endloop-as-instruction-bug-or-feature/m-p/9261018#M1721812</guid>
      <dc:creator>adam_krawczyk1</dc:creator>
      <dc:date>2013-03-04T10:53:15Z</dc:date>
    </item>
    <item>
      <title>Re: Coverage analyzer counts ENDLOOP as instruction: Bug or feature?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/coverage-analyzer-counts-endloop-as-instruction-bug-or-feature/m-p/9261019#M1721813</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Adam,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;If you need only single row value I would recommend to use READ TABLE better.&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in my example, the routine should retrieve an 'X' if the table line (a string) contains the letter 'a' somewhere ( WHERE TABLE_LINE CA 'a' ). It's not possible to write this as a READ TABLE. Or can &lt;STRONG&gt;you &lt;/STRONG&gt;rewrite this with READ TABLE, as you recommend me? (Good luck)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE only allows the equality match on one or more table components, which is only a very restricted type of match condition. The WHERE condition of a loop allows much richer logic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is why I wrote&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;in ABAP, it is a common idiom to use a loop with where condition only for searching for a certain entry. In the table body, you either exit and evaluate the SY-SUBRC after the loop, or you set a return value and leave the modularization unit with RETURN.&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The design is common, it is not forbidden, and there are many cases where it is absolutely necessary. Also, if the statement would be forbidden, ABAP would not allow the amendment "TRANSPORTING NO FIELDS" for the LOOP statement - which only makes sense for this kind of loops.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You argue, the missing coverage of ENDLOOP would be a good indicator if there were subsequent (executable) statements after the RETURN, showing me that this part of the code will not be executed. But if there were statements after the RETURN, then &lt;STRONG&gt;these &lt;/STRONG&gt;statements would not be covered! It is not necessary, and not conveivable, why the ENDLOOP should be counted as executable statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So again the question: Why is ENDLOOP counted as executable statement? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rüdige&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Mar 2013 11:17:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/coverage-analyzer-counts-endloop-as-instruction-bug-or-feature/m-p/9261019#M1721813</guid>
      <dc:creator>Ruediger_Plantiko</dc:creator>
      <dc:date>2013-03-04T11:17:15Z</dc:date>
    </item>
    <item>
      <title>Re: Coverage analyzer counts ENDLOOP as instruction: Bug or feature?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/coverage-analyzer-counts-endloop-as-instruction-bug-or-feature/m-p/9261020#M1721814</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes you are right, I missed importance of where condition in your case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In general I am not fan of exiting loops by return statements instead of condition failure. But LOOP AT is not same as WHILE statement and your example seems to be the the fastest solution for purpose that you need.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For comparison I checked what is behavior for WHILE and IF statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;100 % coverage for IF - 3 statements &lt;/LI&gt;&lt;/UL&gt;&lt;P&gt; &lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/jiveimages/191664" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;75% coverage for DO - 4 statements, 3 covered&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/jiveimages/191663" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So it is strange that there is a different way of coverage measurements:&lt;/P&gt;&lt;P&gt;- ENDIF is not counted at all to coverage.&lt;/P&gt;&lt;P&gt;- ENDDO or ENDLOOP is counted to coverage as not covered.&lt;/P&gt;&lt;P&gt;- ENDMETHOD is counted to coverage as covered line (but METHOD is not counted).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Because it is not consistent, I agree with you finally that ENDLOOP from your example must not be counted as uncovered line. Ending part of statement should be always counted as covered line or not counted at all as in case of ENDIF - common convention should be kept.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Adam&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Mar 2013 12:21:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/coverage-analyzer-counts-endloop-as-instruction-bug-or-feature/m-p/9261020#M1721814</guid>
      <dc:creator>adam_krawczyk1</dc:creator>
      <dc:date>2013-03-04T12:21:54Z</dc:date>
    </item>
    <item>
      <title>Re: Coverage analyzer counts ENDLOOP as instruction: Bug or feature?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/coverage-analyzer-counts-endloop-as-instruction-bug-or-feature/m-p/9261021#M1721815</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Do you know if the bug is already fixed? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Wolfgang&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Aug 2015 10:35:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/coverage-analyzer-counts-endloop-as-instruction-bug-or-feature/m-p/9261021#M1721815</guid>
      <dc:creator>wolfgang_lindner2</dc:creator>
      <dc:date>2015-08-04T10:35:41Z</dc:date>
    </item>
    <item>
      <title>Re: Coverage analyzer counts ENDLOOP as instruction: Bug or feature?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/coverage-analyzer-counts-endloop-as-instruction-bug-or-feature/m-p/9261022#M1721816</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good Evening Rüdiger,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;as far as I know the coverage metric is defined to consider every statement relevant in case one can set a break-point there. In releases &amp;lt; SAP_BASIS 7.50 it is possible to set a BREAK-POINT on ENDLOOP and consequently ENDLOOP is considered as relevant statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the behavior can be considered as feature and is no bug.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this clarifies&lt;/P&gt;&lt;P&gt;&amp;nbsp; Klaus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Aug 2015 21:21:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/coverage-analyzer-counts-endloop-as-instruction-bug-or-feature/m-p/9261022#M1721816</guid>
      <dc:creator>former_member183804</dc:creator>
      <dc:date>2015-08-05T21:21:54Z</dc:date>
    </item>
    <item>
      <title>Re: Coverage analyzer counts ENDLOOP as instruction: Bug or feature?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/coverage-analyzer-counts-endloop-as-instruction-bug-or-feature/m-p/9261023#M1721817</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Rüdiger,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the challenge you experienced "&lt;STRONG&gt;I don't have a chance with any test whatever to reach a statement coverage of 100% for such a form routine" &lt;/STRONG&gt;is tough but still managable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let us assume we want to test the routine CONTAINS_A.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: blue; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;form &lt;/SPAN&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;contains_a&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: blue; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;&amp;nbsp; using&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;it_data&lt;/SPAN&gt;&lt;SPAN style="color: blue; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp; type &lt;/SPAN&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;stringtab&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: blue; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;&amp;nbsp; changing &lt;/SPAN&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;ev_has_a&lt;/SPAN&gt;&lt;SPAN style="color: blue; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;&amp;nbsp; type &lt;/SPAN&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;flag&lt;/SPAN&gt;&lt;SPAN style="color: blue; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: blue; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;&amp;nbsp; loop at &lt;/SPAN&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;it_data&lt;/SPAN&gt;&lt;SPAN style="color: blue; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt; transporting no fields where &lt;/SPAN&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;table_Line&lt;/SPAN&gt;&lt;SPAN style="color: blue; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt; ca &lt;/SPAN&gt;&lt;SPAN style="color: green; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;'a'&lt;/SPAN&gt;&lt;SPAN style="color: blue; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;ev_has_a&lt;/SPAN&gt;&lt;SPAN style="color: blue; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt; = &lt;/SPAN&gt;&lt;SPAN style="color: green; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;'X'&lt;/SPAN&gt;&lt;SPAN style="color: blue; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;. return.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="color: blue; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;&amp;nbsp; endloop.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="color: blue; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;&amp;nbsp; clear &lt;/SPAN&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;ev_has_a&lt;/SPAN&gt;&lt;SPAN style="color: blue; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="color: blue; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;endform.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Shall one regard CONTAINS_A as completely tested in case the return statement is hit. Possibly no, because the clear statement has not been executed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now let us assume we want to test the routine HAS_A.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: blue; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;form &lt;/SPAN&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;has_a&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: blue; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;&amp;nbsp; using&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;it_data&lt;/SPAN&gt;&lt;SPAN style="color: blue; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp; type &lt;/SPAN&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;stringtab&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: blue; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;&amp;nbsp; changing &lt;/SPAN&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;ev_has_a&lt;/SPAN&gt;&lt;SPAN style="color: blue; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;&amp;nbsp; type &lt;/SPAN&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;flag&lt;/SPAN&gt;&lt;SPAN style="color: blue; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: blue; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: blue; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt; clear &lt;/SPAN&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;ev_has_a&lt;/SPAN&gt;&lt;SPAN style="color: blue; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: blue; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;&amp;nbsp; loop at &lt;/SPAN&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;it_data&lt;/SPAN&gt;&lt;SPAN style="color: blue; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt; transporting no fields where &lt;/SPAN&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;table_Line&lt;/SPAN&gt;&lt;SPAN style="color: blue; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt; ca &lt;/SPAN&gt;&lt;SPAN style="color: green; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;'a'&lt;/SPAN&gt;&lt;SPAN style="color: blue; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;ev_has_a&lt;/SPAN&gt;&lt;SPAN style="color: blue; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt; = &lt;/SPAN&gt;&lt;SPAN style="color: green; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;'X'&lt;/SPAN&gt;&lt;SPAN style="color: blue; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;. return.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="color: blue; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;&amp;nbsp; endloop.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="color: blue; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;endform.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Shall one regard HAS_A as completely tested in case the return statement is hit. Possibly no, because the situtation that the internal table IT_DATA contains no 'A' has not been tested.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In both cases one can achieve 100% test coverage by test methods that cover the contain 'A' case and does not contain 'A' case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps&lt;/P&gt;&lt;P&gt;&amp;nbsp; Klaus&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #999999;"&gt;&lt;EM&gt;The night is dark and full of errors ~ Melisandre&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Aug 2015 21:59:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/coverage-analyzer-counts-endloop-as-instruction-bug-or-feature/m-p/9261023#M1721817</guid>
      <dc:creator>former_member183804</dc:creator>
      <dc:date>2015-08-05T21:59:07Z</dc:date>
    </item>
  </channel>
</rss>

