Skip to Content
author's profile photo Former Member
Former Member

Abap Unit Tets Question


I want to do a unit test for Fm ,but the FM input have some value that always changing and other

Are stay the same ,and the FM output change accordingly , i can build a unit test for this kind of FM,

Or it's worthless ?


Ricardo Arona

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Jan 14, 2009 at 03:37 PM

    It all depends on the purpose of your Function module.

    If you are only selecting some records from the database into output based on your inputs, than it is not advisable to write ABAP unit test on that FM.

    But your FM invovles some kind of processing i.e. collecting table, modifying data in to internal table, filling up final table etc than you should write ABAP Unit only on that Subroutine.

    Check this recent discussion:

    Unit Test Problem


    Naimesh Patel

    Add a comment
    10|10000 characters needed characters exceeded

    • Do you select DECISION_KEY, USER_ID, OPERATION_ID from the Database based on the WORKITEM_ID? If yes, than you should NOT write a Unit Test because data in the database can be changed and it leads to failure of your ABAP test in Future.


      Today, For

      WORKITEM_ID - 005104574

      You get:

      DECISION_KEY - 0001

      USER_ID - C0267195


      But Someone changed OPERATION_ID from EXEC to PLAN.

      So, after the changed OPERATION_ID your test will fail because you have hardcoded the OPERATION_ID as EXEC in your ABAP Unit. This test would fail because the data got changed, not the logic. So, it doesn't serve the purpose of writing the unit test.


      Naimesh Patel

  • Posted on Jan 14, 2009 at 03:33 PM


    just a suggestion.

    Create a variant for the testing of the function module (the save icon after input the FM parameters).

    Call always that test variant and change the only values that you have to change.



    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.