<?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 TDD: Using Test-Data Containers(eCATT) in Unit-test in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/tdd-using-test-data-containers-ecatt-in-unit-test/m-p/10476281#M1849758</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Recently I learned about TDD, and learn how to write unit-test for some class. But When I write a report(with DB, post account doc) , I come across some problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. I&amp;nbsp; have some method just select some data form table , but I don't know how to write this unit-test? I know I can create a TDC though eCATT, but my method is select form table ,how do I finish this ?&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/jiveimages/513409" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Also I have some method just handle data, such as check the data or move to another internal table, do I need to write unit-test for this kind method?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Further more , I search the SCN many times , I didn't find a suitable program as TDD program (include SQL, input , output, data handle ). Is there anyone can share your example in TDD for us , thank you so much.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 05 Aug 2014 09:33:11 GMT</pubDate>
    <dc:creator>former_member189009</dc:creator>
    <dc:date>2014-08-05T09:33:11Z</dc:date>
    <item>
      <title>TDD: Using Test-Data Containers(eCATT) in Unit-test</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/tdd-using-test-data-containers-ecatt-in-unit-test/m-p/10476281#M1849758</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Recently I learned about TDD, and learn how to write unit-test for some class. But When I write a report(with DB, post account doc) , I come across some problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. I&amp;nbsp; have some method just select some data form table , but I don't know how to write this unit-test? I know I can create a TDC though eCATT, but my method is select form table ,how do I finish this ?&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/jiveimages/513409" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Also I have some method just handle data, such as check the data or move to another internal table, do I need to write unit-test for this kind method?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Further more , I search the SCN many times , I didn't find a suitable program as TDD program (include SQL, input , output, data handle ). Is there anyone can share your example in TDD for us , thank you so much.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Aug 2014 09:33:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/tdd-using-test-data-containers-ecatt-in-unit-test/m-p/10476281#M1849758</guid>
      <dc:creator>former_member189009</dc:creator>
      <dc:date>2014-08-05T09:33:11Z</dc:date>
    </item>
    <item>
      <title>Re: TDD: Using Test-Data Containers(eCATT) in Unit-test</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/tdd-using-test-data-containers-ecatt-in-unit-test/m-p/10476282#M1849759</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Glad that you have interest in TDD. I write on &lt;A href="http://zevolving.com/category/abapobjects/abap-unit-test/"&gt;ABAP unit&lt;/A&gt; at my site &lt;A href="http://zevolving.com/"&gt;zevolving.com&lt;/A&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TDD should not dependent on the data selection from the DB as the DB data could be changed and your test would fail without you being changing the logic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To avoid the dependency on the data, you need to prepare the dummy test data. You need to than also prepare the expected output from the dummy test data. Once you have the dummy test data, you can pass the data to the method (or subroutine or FM) and get the actual output. You compare the expected output with the actual output to verify it works as expected.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For your example, you should modularize the program - method for GET_DATA, method for PREPARE_OUTPUT, method for GENERATE_OUTPUT. From these methods, you should be able to write unit test on PREPARE_OUTPUT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your unit test, you need to declare local variables in your test class if you use the subroutine. if you use the class and methods, you can instantiate the object and you get all the variable access. Thats the reason it would be more easier and less confusing when using the objects with unit test.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Fill up these tables. Say LT_VBRK, LT_VBFA, LT_VBAK. Make sure your subroutine PREPARE_OUTPUT has importing parameters. Pass these to them. Also, prepare the LT_OUTPUT_EXP with the expected results. Declare the table which would hold the actual values LT_OUTPUT_ACT and receive the results from the subroutine PREPARE_OUTPUT. Use the method&amp;nbsp; cl_aunit_assert&lt;SPAN class="L0S70"&gt;=&amp;gt;&lt;/SPAN&gt;assert_equals to check the values in the LT_OUTPUT_EXP and LT_OUTPUT_ACT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Naimesh Patel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Aug 2014 15:48:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/tdd-using-test-data-containers-ecatt-in-unit-test/m-p/10476282#M1849759</guid>
      <dc:creator>naimesh_patel</dc:creator>
      <dc:date>2014-08-05T15:48:37Z</dc:date>
    </item>
    <item>
      <title>Re: TDD: Using Test-Data Containers(eCATT) in Unit-test</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/tdd-using-test-data-containers-ecatt-in-unit-test/m-p/10476283#M1849760</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you so much! it help me a lot to understand the TDD.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Aug 2014 06:18:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/tdd-using-test-data-containers-ecatt-in-unit-test/m-p/10476283#M1849760</guid>
      <dc:creator>former_member189009</dc:creator>
      <dc:date>2014-08-06T06:18:16Z</dc:date>
    </item>
  </channel>
</rss>

