Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Abap Unit Tets Question

Former Member
0 Kudos

Hi,

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 ?

Regards

Ricardo Arona

1 ACCEPTED SOLUTION

naimesh_patel
Active Contributor
0 Kudos

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:

Regards,

Naimesh Patel

4 REPLIES 4

andrea_galluccio2
Contributor
0 Kudos

Hi,

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.

Bye

Andrea

naimesh_patel
Active Contributor
0 Kudos

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:

Regards,

Naimesh Patel

0 Kudos

Hi Naimesh,

But your FM involves 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.

Yea , my FM get always different key.

the WORKITEM_ID is unique and always changing.

like :

Import

WORKITEM_ID - 005104574

DECISION_KEY - 0001

USER_ID - C0267195

OPERATION_ID - EXEC

so the export data is always changing accordingly .

What u suggest for this kind of issue?

Regards

0 Kudos

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.

E.g.

Today, For

WORKITEM_ID - 005104574

You get:

DECISION_KEY - 0001

USER_ID - C0267195

OPERATION_ID - EXEC

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.

Regards,

Naimesh Patel