Hi Experts, questions about abap unit test(abap oo)?

Hi Experts,
I am learning abap unit test, could you please tell me some info about how I can test the performance of some specific code in my program? can abap unit test do this kind of job? and could you please tell me what I can do using abap unit test? and some classic examples are appreciated, thanks in advance!
Kind regards
Dawson

Hi
Below documents will give you more information,
http://help.sap.com/saphelp_nw04/helpdata/en/a2/8a1b602e858645b8aac1559b638ea4/content.htm
ABAP Testing and Troubleshooting [original link is broken]
http://bi.offis.de/publicProject/g16cglafhqva.htm
regards
Nagaraju

Similar Messages

  • Hi Experts, need an example for abap unit test(ABAP OO)?

    Hi Experts,
    I want to do abap unit test for the developed programs, could anyone please give me an example program of development(a simple is ok, just use it to test)? and an abap unit test example for the program, what I want is to use object oriented abap, thanks in advance!
    Merry Christmas to you all.
    Kind regards
    Dawson

    Hi
    Below documents will give you more information,
    http://help.sap.com/saphelp_nw04/helpdata/en/a2/8a1b602e858645b8aac1559b638ea4/content.htm
    ABAP Testing and Troubleshooting [original link is broken]
    http://bi.offis.de/publicProject/g16cglafhqva.htm
    regards
    Nagaraju

  • Transport of ABAP Unit Test Classes between systems.

    Hi guys
    I have a bit of a dilemma on hands here pertaining to the transport of ABAP Unit test classes. Generally when you create a transport containing classes the transport manager will automatically include all "programs" related to the class like the local type definitions, local implementations and with ABAP Unit the local test classes.
    <b>The question that I have is how would one go about excluding the ABAP Unit test classes in transports to production systems and pre-WAS 6.40 systems that do not support ABAP Unit? Does the transport system automatically manage this for you?</b> Any help ideas regarding this would be greatly appreciated.
    Kind regards
    Ettienne Hugo

    Hello Ettienne
    I have a very similar problem that I have to maintain objects for release 6.20 and 6.40. Since I appreciate ABAP Unit Tests as being very helpful I do not want to miss them even in such a situation.
    My approach is as following:
    - If possible, I try to separate the local classes from the tested object, for example:
    - Report or function group
         - contains an include like <z_include_ft01>
                - Within <i><z_include_ft01></i> I have a single stament <i><z_include_au01></i>
    The actual ABAP Unit Tests are coded in <z_include_au01>. Now if I need to ship the development to a release < 6.40 the only thing I need to do is to comment the single INCLUDE statement in <z_include_ft01>. This manual step cannot be ommitted (however, it would be simple task to define an eCATT doing this). In addition, include <z_include_au01> should not be in the transport request for the development (if it happened the import error would not affect the function of the development because it is no longer linked together).
    Advantage of this approach:
    - I clearly see that my development contains ABAP Unit Tests (use naming conventions for the includes) and
    - I can ship - with little effort - the development to SAP releases not supporting ABAP Unit Testing yet
    Regards
      Uwe

  • ABAP Unit Test Problem

    Here we go again on questions regarding ABAPUnit.  We are trying to use Abap unit within a Class object.  All the examples we have seen have to do with Classes and Methods within a Report program. 
    What we have created:
    Class: ZCL_MAIN
    Type: General Class
    Method:  test_abapunit
    Class: ZCL_MAIN_TEST
    Class type: Abap Unit
    Sub Class of ZCL_MAIN
    Method: Test_abapunit_test 
    We try and run the Abap Unit Test from the Test Class and it says it is complete but does not execute our code.  I know we are doing something wrong but are stumped as to what it is.
    Glenn

    Hi Glenn,
    although Uwe and Klaus actually provided for the relevant information we too faced some difficulties at first understanding 'where' you actually put the test classes. So here are the mechanics:
    Open SE80 or SE24 and implement your class ZCL_MAIN.
    While this class is opened, choose <i>Goto->Class-local types->Local Class Definitions/Types</i> from the menu. An editor for local classes is opened on the right.
    Type in your class definition ZCL_MAIN_TEST like this:
    CLASS lcl_main_test DEFINITION FOR TESTING.
      "#AU Risk_Level Harmless
      PRIVATE SECTION.
        CONSTANTS: some_initial_test_value TYPE i VALUE 5.
        DATA: main_class TYPE REF TO zcl_main.
        METHODS setup     FOR TESTING.
        METHODS teardown  FOR TESTING.
        METHODS check_get_my_int FOR TESTING.
        METHODS check_.. FOR TESTING.
    ENDCLASS.
    This is btw a 'normal' local class, no subclass of cl_abap_unit.. whatsoever.
    Go back (menu <i>Goto->Class Definition</i>).
    Choose <i>Goto->Class-local types->local class implementations</i> from the menu.
    Type in your class implementation for ZCL_MAIN_TEST, i.e. implement especially the setup()-method for the test fixture and the various test-methods.
    Compile/activate your class ZCL_MAIN.
    Run the test by choosing <i>Test->Unit Test</i> from the context menu of the class ZCL_MAIN.
    Hope this helps, regards,
    Sebastian

  • ABAP unit: test classes part of prod. code

    Hi all,
    I've read <a href="https://weblogs.sdn.sap.com/pub/u/266">Thomas Weiss</a>'s weblog: <a href="/people/thomas.weiss/blog/2004/12/17/a-spotlight-on-abap-unit-part-1 Spotlight on ABAP Unit Part 1</a>.
    I posted a question there, but apparently Thomas can't answer at the moment, and since I'm impatient for getting someone's opinion, I reckon we can discuss that topic here  :^)
    As explained in the <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/c1be1003-0701-0010-3795-f87160de6483">NetWeaver Developer’s Guide Using ABAP</a>, the test classes are part of the program under test (PUT):
    <i>In ABAP Unit, test classes are part of the production code of the TU. This avoids problems arising from the test code being separate from the production code:
    - Programs and tests must be kept synchronized.
    - You have to ensure that the test and program code are transported together.
    - External test code only enables black box tests with an outside perspective of the tested program.
    Since the test code is part of the production code, it is easy to keep the unit tests and the
    production code up to date if the latter is changed.
    Although the test code and the production code are transported through the system landscape, ABAP unit tests do not increase the load on the production system. By default, the test code is not compiled in the production system. Therefore, the test code can never be executed in the production system.</i>
    On the other hand, this idea is quite different from what suggested by other unit testing frameworks.
    For instance, the documentation of <a href="http://www.ruby-doc.org/stdlib/libdoc/test/unit/rdoc/classes/Test/Unit.html">Test::Unit - Ruby Unit Testing Framework</a> reads:
    <i>It‘s handy to collect a bunch of related tests, each test represented by a method, into a common test class that knows how to run them.
    The tests will be in a separate class from the code they‘re testing for a couple of reasons. First of all, it allows your code to stay uncluttered with test code, making it easier to maintain. Second, it allows the tests to be stripped out for deployment, since they‘re really there for you, the developer, and your users don‘t need them. Third, and most importantly, it allows you to set up a common test fixture for your tests to run against.</i>
    Regarding the advantages outlined by NetWeaver Developer’s Guide:
    - Programs and tests might be kept synchronized even if they don't belong to the same unit of code.
    - Moreover, you could assure that the test and program code are transported together by saving them in the same package.
    - And quite frankly, I don't have a thourough understanding of the reason why external tests only allow <i>black box tests with an outside perspective</i>.
    What are your opinions on this?
    Regards, Davide

    Hi,
    when I started unit testing with JUnit I was quite surprised that SAP groups the tests with the production code. But now I actually really like it. It has a few advantages:
    - Good tests serve as an excellent documentation so why not bundling them together.
    - If you want to look at the tests they are easy to find.
    - I write all my class tests as local classes. I found out that it really helps me to focus on writing tests only for the class under test. Sometimes it is quite easy to forget the "unit" and write integration tests again.
    Regarding your question:
    >And quite frankly, I don't have a thourough understanding of the reason why external tests only allow black box tests with an outside perspective.
    Usually I would not use the term black box testing in this context. Maybe you mean that it is easy to access private attributes, methods when you group class and testclass together?
    Normally black box testing means that you cannot look at the implementation of the code under test. So your tests are based on the specifications or if there is not one, on your common sense.
    cheers
    Thomas

  • Creating ABAP Unit Tests for Report Programs

    How can we create ABAP unit test  for report programs.
    Please explain the steps?

    Hi Devendra.
    I would like to suggest some references which are as below:
    [SAP HELP - Complete ABAP unit|http://help.sap.com/saphelp_nw04/helpdata/en/a2/8a1b602e858645b8aac1559b638ea4/frameset.htm]
    [SDN - Reference for ABAP unit testing|about unit testing;
    Hope that's usefull.
    Good Luck & Regards.
    Harsh Dave
    Edited by: Harsh Dave on Jul 14, 2008 2:13 PM
    Edited by: Harsh Dave on Jul 14, 2008 2:20 PM

  • How to count the number of test ABAP Unit test methods

    I need to count the number of test methods of a class.   Has anybody done this before?   For example, if I have a class that has 3 methods and I wrote 6 abap unit test methods for it.   I can count the number of methods using cl_abap_classdescr=>describe_by_name (which gave me 3 from my example) but I could not find the function module to count the number of test methods (which should give me 6 in my example).
    I appreciate your reply.

    This call does thew trick.  I just had to make sure the prog name that I pass has "CP" from the 30th pos for it return the result.   Here is thew subroutine that I use:
    form get_test_method_count using     query_class
                               changing  test_method_count.
      data: l_progname type progname.
      l_progname = query_class.
      l_progname+30 = 'CP'.  "needed so the following method will recognize this as a class
      data: l_result type if_aunit_prog_info_types=>ty_t_testclasses.
      try.
          call method cl_aunit_prog_info=>get_tests_of_program
            exporting
              progname = l_progname
            receiving
              result   = l_result.
          if l_result is not initial.
            data: result_rec like line of l_result.
            loop at l_result into result_rec.
              test_method_count = lines( result_rec-methods ).
            endloop.
          endif.
        catch cx_root.
      endtry.
    endform.

  • ABAP Unit on ABAP Sneak Preview 2004s

    I am trying to look at ABAP Unit within ABAP Sneak Preview 2004s.  Upon trying I get a message 'The system settings prevent the use of unit tests in this client'.  I have gone to transaction SAUNIT_CLIENT_SETUP but it will not allow me to uncheck 'Prohibit Unit Tests' option. 
    Does anyone have any suggestions?  I would like to look at this and demo to the group as our 'real' ECC6 environment will not be available for some time.
    Glenn

    Hi Glenn, I have the same preview and when I run the tcode it gives me a screen, where the checkbox(prohibit unit test) is already unchecked.  All is greyed out, but there is a change mode icon on the application toolbar.  When I click this button it is allowing me to change the value.  What client are you working in, I'm working in client 001.
    Regards,
    Rich Heilman

  • ABAP UNIT - Test Driven Development

    Dear ABAPers,
    I hope some of you may have also ventured into this area of Test Driven Development.  I have just started looking into this new and exciting way of development.  My understanding after having gone through the available blogs and some reading material on TDD, is that, we have to religiously embrace Object Oriented programing to actually benefit from TDD methodology.  That raised a big question in my mind, how do we implement this technique when we are coding in the user exits like MV45AFZZ, which is mostly classical ABAP programming?
    Please help me understand the TDD a bit more than I currently do.
    Thanks much,
    SMA.
    <- removed by moderator ->
    Edited by: Neil Gardiner on Sep 29, 2010 10:38 AM

    As Dirk already mentioned TDD is writing test before writing productive code. This approach is not limited to OO practices or unit tests.
    E.g. writing an eCatt script in advance that passes as soon the scenario is working, adheres to TDD practices also..
    Vice versa if one practices unit testing and oo patterns it is no TDD if the tests are written after the productive code.
    Regards
      Klaus

  • Abap unit test debug

    when use unit test,how to start up debug model?

    You can put breakpoints in your unit test methods (or helper methods) the same way you can in regular ABAP. As long as it is being executed in the foreground it should be tripped. I have noticed some quirky behavior about when it allows me to place a breakpoint in the code and when it places the breakpoint on the report statement at the beginning of my program, but it IS possible. I do it frequently.
    Regards,
    Andy

  • ABAP UNIT TEST

    Hi ,
    I am new to oops concept but i am able to understand.
    Now i have to create some Unit test plans in ABAP.We are using SAP Netwever 7.1 and WEB AS 6.0
    I tried from SE24 but i couldn't get the correct path.
    Can you please explain me: if i have a Z program then where and how to write number of Unit test classes. And how it will integrate to with our actual program/FM/any object
    Thanks
    Umashankar.

    You can create the ABAP Unit class as a local class in your program, FM, or class which will test the functionality of that individual code lines. Once you implement the ABAP Unit, you can then run the Unit Test by main menu > Execute > Unit Test. E.g. from Program, Program > Execute > Unit Test.
    Check this previous discussions:
    ABAP Unit, how to use
    Unit Testing concept
    Regards,
    Naimesh Patel

  • Issue in ABAP Unit Test

    Hi,
    I am having an issue in Unit Testing of Function Module. The issue is that Interface parameter of FM is not accessed in subroutine as the parameter goes like a field symbol. I get a dump while try to access the Interface parameter.
    Can anyone please help me out on this.

    * Following is my Unit Test Method
    METHOD get_user_formats.
         DATA lv_format   TYPE char35.
         PERFORM get_user_formats USING '2'.
         READ TABLE user_format INTO lv_format INDEX 1.
         " Expected Result
         cl_aunit_assert=>assert_equals( act = lv_format
                                         exp = 'DATE = MM/DD/YYYY').
       ENDMETHOD.     
    FORM get_user_formats USING datfm TYPE datfm.
       DATA: lv_format   TYPE char35.
       SELECT SINGLE ddtext FROM dd07t INTO lv_format
              WHERE domname = 'XUDATFM' AND
                   ddlanguage =  sy-langu AND domvalue_l = datfm.
       CONCATENATE 'DATE = ' lv_format INTO lv_format SEPARATED BY space.
       APPEND lv_format TO user_format.
       CLEAR lv_format.
    * Comment: user_format is a table in TABLES parameter of FM. It is having single field of type CHAR35
    ENDFORM.                    " get_user_formats
    Please note that I get dump ONLY at the time UNIT TESTING. Otherwise the program is running fine.

  • How to make a Abap Unit Test Suit with many test classes

    Hi,
    Problem space
    we have different packages(embedded) in our project and each package corresponds to a differnt functional layer in the design.
    We want to create abab unit test classes for these different layers.
    say embedded package 1 has 10 unit test classses
          embedded package 1 has 20 unit test classses
    How to grup these classes together so that we can start them frm a test suite.
    Code examples and blogs links will be appreciated.
    regards
    anubhav

    This sounds a bit like Project Administration 101 to me.
    I'm not exactly sure what you are actually trying to do here --but generally if you want to functionally test something you need to start with a business process -
    You need to create scripts which tell the user the data to be entered, the transaction to be used and the outcome.
    With SAP you might need to show screen shots of each stage as well.
    You follow this for each complete business process until you've covered the whole business cycle.
    You complete this say individually for Logistics, Purchasing and Finance and then compare what SAP gives you with what you expected to get.
    For some type of testing CATTS can help but without the business processes any testing is essentially meaningless.
    It is totally pointless trying to design a "generic" test plan until you've got the functional consultants to describe the business processes involved.
    Cheers
    jimbo

  • Question about writing Junit test for SQLj application

    Just inherite a SQLj application without unit test. After making few enchancement I plan to add unit test about it to make it more solid. What I plan to do is invoke SQLj translator dynamically to generate java source, then compile and invoke the result class dynamically at Junit test. Does anyone how to call SQLj translator as an API call ??

    I guess I might add that the error I am getting is
    java.lang.nullPointerException
    i've got this now:
         public E top() throws EmptyStackException {
              if (numItems == 0)
                   throw new EmptyStackException("Stack is empty");
              return S[numItems--];
         }With the same test, as it would throw an emptystackexception not a full..
    But the test still doesn't pass.

  • Questions about Real Application Testing(RAT)

    Hi All,
    We have a production database running on 10gR3 on a server with local drives, while we have a Oracle 11gR2 DB running on a server with NFS mounts (using S7310 - AmberRoad) i.e. Faster and better storage.
    We captured the load on 10gR3 and replayed it on 11gR2. We noticed the following:
    (1) Replay is considerably slow even though Oracle11gR2 instance has a faster storage. We suspect that it may be something to do with the buffer cache / SGA because there is nothing in cache on the target (we didn't shutdown 10gR2 DB for capture) – what should we do then?
    (2) To make sure that we can take the advantage of cache, we replayed the load 2nd time right after the 1st replay and everything ran to our surprise. So we are wondering how’s that possible since we did not restore the DB as we do not want to wipe off the cache (chicken and egg situation)? Does Oracle rollback the changes after the replay?
    (3) Do we have to restore database on Target every time we do replay? But if we do that then we won't have anything in the SGA.
    So we need your advise and also would like to know how everyone else is doing this testing?
    Regards,
    RJiv.

    DB Replay's workload capture facility allows you to either start capture from a closed (mounted) database (capture starts upon opening the DB), or to begin capture mid-stream during normal activity. Starting capture on the production system from a closed database eliminates the divergence in performance resulting from a primed cache, as well as possible data divergence issues from open, partially-completed transactions at the time the capture started.
    For many customers, it will clearly not be possible to close their database during peak periods (!!)
    One way to address the cache priming issue is to start capture in production from a closed state during a low period of activity, and the allow capture to run through the peak period.
    Another approach is to start capture mid-stream with the DB open and to run capture for a long period (long enough to stabilize the cache). When performing the replay, begin a new AWR snapshot after the cache has stabilized.
    Your question about running the replay again after the first replay is done is confusing. Of course you will not get meaningful data from that, since replay must begin from the capture start SCN. If you run replay twice in a row without reverting the database to the capture start SCN, it will be applying meaningless changes to a database in a state that is unlike that of the original. You will be testing the data errors codepath instead of real performance.
    It is typical to enable database flashback on the repay database so that it can be repeatedly reverted to the capture start SCN for testing under a variety of scenarios.
    Regards,
    Jeremiah Wilton
    Blue Gecko, Inc.
    http://www.bluegecko.net

Maybe you are looking for

  • Custom File Naming

    Is there any way to save a custom file naming routine into a preset?

  • [SOLVED] wlan0 not detected

    My wireless network worked previously with these in /etc/rc.conf: wlan0="dhcp" wlan_wlan0="wlan0 essid blah key blah" WLAN_INTERFACES=(wlan0) INTERFACES=(wlan0) Now it's stopped working for some reason and cannot even be detected, let alone configure

  • Spatial query to find all partially aligned lines

    Hi There. I need to find all partially aligned polylines in the layer (interiors have 1-dimentionali intersection). Actually, polylies may a little fluctuate along each other, but that spatial disjointment shouldn't exceed some certain tolerance. It

  • Access other schema to check details

    I am updating certain rows (contain coupons information) in the db with a particular condition Before updaing i need to check whether those are in active status in an other schema which has relevant info related to coupons do i need nested am's to do

  • Possible to replay first-time startup video?

    Hi all Was wondering if it is possible to replay the startup video that plays the first time a new iMac is booted up. If so, how? I found it on You Tube, but it's not the same and want to show someone else who missed the initial boot. Thanks in advan