<?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 Unit testing in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/unit-testing/m-p/3319290#M795105</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi &lt;/P&gt;&lt;P&gt;can you plz explain me about Unit testing?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks in advance&lt;/P&gt;&lt;P&gt;bramara&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 31 Jan 2008 14:14:00 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-01-31T14:14:00Z</dc:date>
    <item>
      <title>Unit testing</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/unit-testing/m-p/3319290#M795105</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi &lt;/P&gt;&lt;P&gt;can you plz explain me about Unit testing?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks in advance&lt;/P&gt;&lt;P&gt;bramara&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jan 2008 14:14:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/unit-testing/m-p/3319290#M795105</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-01-31T14:14:00Z</dc:date>
    </item>
    <item>
      <title>Re: Unit testing</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/unit-testing/m-p/3319291#M795106</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ABAP Unit Tests enable you to write test cases for certain Methods, to check their behaviour and displaying a appropriate protocoll.&lt;/P&gt;&lt;P&gt;These test cases are implemented using usual ABAP classes / methods and can be executed via menü in SE24: Class -&amp;gt; Unit Test&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jan 2008 14:16:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/unit-testing/m-p/3319291#M795106</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-01-31T14:16:03Z</dc:date>
    </item>
    <item>
      <title>Re: Unit testing</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/unit-testing/m-p/3319292#M795107</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is an example of a local class and a local unit test implemented in the same report. Pressing Ctrl+F10 in ABAP editor will execute the Unit Test:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
************************************************************************
* CLASS LCL_TO_BE_TESTED DEFINITION                                    *
************************************************************************
* Definition of local Class LCL_TO_BE_TESTED to be tested using ABAP   *
* Unit Tests                                                           *
************************************************************************
CLASS lcl_to_be_tested DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS:
      return_a
        RETURNING
          value(return) TYPE string.
ENDCLASS. "CLASS lcl_to_be_tested DEFINITION


************************************************************************
* CLASS LCL_TO_BE_TESTED IMPLEMENTATION                                *
************************************************************************
* Implementation of local Class LCL_TO_BE_TESTED to be tested using    *
* ABAP Unit Tests                                                      *
************************************************************************
CLASS lcl_to_be_tested IMPLEMENTATION.
  METHOD return_a.
    return = 'A'.
  ENDMETHOD. "METHOD return_a
ENDCLASS. "CLASS lcl_to_be_tested IMPLEMENTATION




************************************************************************
* CLASS LCL_TEST DEFINITION                                            *
************************************************************************
* Definition of local Class LCL_TEST, which implements the ABAP Unit   *
* Test for local Class LCL_TO_BE_TESTED                                *
************************************************************************
CLASS lcl_test DEFINITION FOR TESTING.
  PUBLIC SECTION.
    CLASS-DATA:
      c_ts_start    TYPE i READ-ONLY,
      c_ts_end      TYPE i READ-ONLY,
      c_dur         TYPE i READ-ONLY,   "duration of all test methods
      r_runtime     TYPE REF TO if_abap_runtime READ-ONLY,
      c_no_of_tests TYPE i READ-ONLY.   "number of test methods executed

    DATA:
      m_ts_start    TYPE i READ-ONLY,
      m_ts_end      TYPE i READ-ONLY,
      m_dur         TYPE i READ-ONLY.   "duration of test method


  PROTECTED SECTION.


  PRIVATE SECTION.
    CLASS-METHODS:
      class_setup,
      class_teardown.

    METHODS:
      test__return_a FOR TESTING,
      test__return_b FOR TESTING,
      setup FOR TESTING,
      teardown FOR TESTING.
ENDCLASS. "CLASS lcl_test DEFINITION FOR TESTING


************************************************************************
* CLASS LCL_TEST IMPLEMENTATION                                        *
************************************************************************
* Implementation of local Class LCL_TEST, which implements the ABAP    *
* Unit Test for local Class LCL_TO_BE_TESTED                           *
************************************************************************
CLASS lcl_test IMPLEMENTATION.

* **********************************************************************
* * METHOD TEST__RETURN_A                                              *
* **********************************************************************
* * 1st Test-Method to check, whether static Method RETURN_A of local  *
* * Class LCL_TO_BE_TESTED returns the Value 'a'                       *
* **********************************************************************
  METHOD test__return_a.
    DATA:
      lv_return TYPE string.

    lv_return = lcl_to_be_tested=&amp;gt;return_a( ).

    cl_aunit_assert=&amp;gt;assert_equals( act = lv_return
                                    exp = 'a' ).
  ENDMETHOD. "METHOD test__return_a


* **********************************************************************
* * METHOD TEST__RETURN_B                                              *
* **********************************************************************
* * 2nd Test-Method to check, whether static Method RETURN_A of local  *
* * Class LCL_TO_BE_TESTED returns the Value 'A'                       *
* **********************************************************************
  METHOD test__return_b.
    DATA:
      lv_return TYPE string.

    lv_return = lcl_to_be_tested=&amp;gt;return_a( ).

    cl_aunit_assert=&amp;gt;assert_equals( act = lv_return
                                    exp = 'A' ).
  ENDMETHOD. "METHOD test__return_b


* **********************************************************************
* * METHOD CLASS_SETUP                                                 *
* **********************************************************************
* * Method used by ABAP Unit Test to start a Unit Test. Executed only  *
* * once upon Start of an ABAP Unit Test.                              *
* **********************************************************************
  METHOD class_setup.
*   initialize Runtime Timer -&amp;gt; LCL_TEST=&amp;gt;R_RUNTIME
    lcl_test=&amp;gt;r_runtime = cl_abap_runtime=&amp;gt;create_hr_timer( ).

*   get 1st runtime timestamp (Class) -&amp;gt; LCL_TEST=&amp;gt;C_TS_START
    lcl_test=&amp;gt;c_ts_start = lcl_test=&amp;gt;r_runtime-&amp;gt;get_runtime( ).
  ENDMETHOD. "METHOD class_setup


* **********************************************************************
* * METHOD CLASS_TEARDOWN                                              *
* **********************************************************************
* * Method used by ABAP Unit Test to end a Unit Test. Executed only    *
* * once upon End of an ABAP Unit Test.                                *
* **********************************************************************
  METHOD class_teardown.
*   get 2st runtime timestamp (Class) -&amp;gt; LCL_TEST=&amp;gt;C_TS_END
    lcl_test=&amp;gt;c_ts_end = lcl_test=&amp;gt;r_runtime-&amp;gt;get_runtime( ).

*   calculate overall runtime of ABAP Unit Test
*   -&amp;gt; LCL_TEST=&amp;gt;C_DUR
    lcl_test=&amp;gt;c_dur = c_ts_end - c_ts_start.
  ENDMETHOD. "METHOD class_teardown


* **********************************************************************
* * METHOD SETUP                                                       *
* **********************************************************************
* * Method used by ABAP Unit Test to initialize the Execution of a     *
* * Test Run (^= Execution of a Test-Method).                          *
* **********************************************************************
  METHOD setup.
*   count number of test methods executed during ABAP Unit Test
*   -&amp;gt; LCL_TEST=&amp;gt;C_NO_OF_TESTS
    ADD 1 TO lcl_test=&amp;gt;c_no_of_tests.

*   get 1st timestamp (Test-Method) -&amp;gt; ME-&amp;gt;M_TS_START
    me-&amp;gt;m_ts_start = lcl_test=&amp;gt;r_runtime-&amp;gt;get_runtime( ).
  ENDMETHOD. "METHOD setup


* **********************************************************************
* * METHOD TEARDOWN                                                    *
* **********************************************************************
* * Method used by ABAP Unit Test to conclude the Execution of a Test- *
* * Run (^= Execution of a Test-Method).                               *
* **********************************************************************
  METHOD teardown.
*   get 2nd timestamp (Test-Method) -&amp;gt; ME-&amp;gt;M_TS_END
    me-&amp;gt;m_ts_end = lcl_test=&amp;gt;r_runtime-&amp;gt;get_runtime( ).

*   calculate duration of Test-Method -&amp;gt; ME-&amp;gt;M_DUR
    me-&amp;gt;m_dur = m_ts_end - m_ts_start.
  ENDMETHOD. "METHOD teardown
ENDCLASS. "CLASS lcl_test IMPLEMENTATION

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jan 2008 14:24:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/unit-testing/m-p/3319292#M795107</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-01-31T14:24:05Z</dc:date>
    </item>
  </channel>
</rss>

