Application Development and Automation 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: 
Read only

ABAP unit testing for smartforms

vinitha_raj3
Explorer
3,220

For a smartform driver program, I am implementing unit test class. It is working till the point the data is passed to the smartform function module.

I wanted to know is there any way to check the smartform elements, like for eg:

  • programmatically can we check if two windows are overlapping?
  • Or any element missing to populate?
  • Or any window is not at the position as per requirement?
10 REPLIES 10
Read only

Sandra_Rossi
Active Contributor
0 Likes
2,725

That would be an interesting tool but I've never heard of it.

Moreover, it depends on what you really want to test. Is it (1) the driver or (2) the smart form itself?

  1. You just need to check the values of parameters sent to the smart form
  2. You may execute the smart form, retrieve the result as OTF format and check more or less easily the field positions, texts, etc.
Read only

vinitha_raj3
Explorer
0 Likes
2,725

Thanks for replying.

I want to test the smartform.

Imagine some one else has created the smartform and I don't want to go and check it manually.

I want a tool to do it and give me results, saying all are as per requirement.

For other types of programs, I can do it with ABAP test class. But smartform, seems like somebody has to manually verify it.

Read only

vinitha_raj3
Explorer
2,725

Thanks for replying.

Actually I think you didn't get my query.

Imagine some one else has created the smartform and I don't want to go and check it manually.

I want a tool to do it and give me results, saying all are as per requirement.

For other types of programs, I can do it with ABAP test class. But smartform, seems like somebody has to manually verify it.

Read only

FredericGirod
Active Contributor
0 Likes
2,725

I saw formulaire test tool, but it was outside from SAP.

I think ABAP Unit could not really used in Smartforms, because smartforms are not real ABAP & are definitively not Clean Coded.

What you could test, is the XML output of the form. But it is only a test about CHAR.

Read only

MateuszAdamus
Active Contributor
0 Likes
2,725

Hi vinitha.raj3

There is a class called CL_SSF_FB_SMART_FORM which allows for some basic operations on a Smart Form. I have not used it, but it seems that it's possible to execute a CHECK on the loaded form and return its XML structure. This could be a good start for Smart Form tests.

ATA:
  lo_ixml         TYPE REF TO if_ixml,
  lo_xml_document TYPE REF TO if_ixml_document.

lo_ixml = cl_ixml=>create( ).
lo_xml_document = lo_ixml->create_document( ).

DATA(lo_sf) = NEW cl_ssf_fb_smart_form( ).
TRY.
    CALL METHOD lo_sf->load
      EXPORTING
*       im_active      = SPACE
        im_formname    = 'THE_NAME_OF_THE_SMART_FORM'
*       im_language    = SY-LANGU
      IMPORTING
        ex_fmnumb      = DATA(lv_fmnumb)
        ex_fmnumb_test = DATA(lv_fmnumb_test).
  CATCH cx_ssf_fb .
    RETURN.
ENDTRY.

" lo_sf->check( ). <-- method to check the Smart Form

CALL METHOD lo_sf->xml_download
  EXPORTING
    parent   = lo_xml_document
  CHANGING
    document = lo_xml_document.
Regards,
Mateusz
Read only

0 Likes
2,725

With the code above, you'll get the definition of the Smart Form (in format "SFXML"), I think the question is more about testing the form output with some input data.

I think that testing the Smart Form description is as useless as testing the existence of methods A and B of a given class...

Read only

0 Likes
2,725

Hi Sandra,

I know it's a definition. But definition should be a start in this case.

If the definition is incorrect, e.g.: one of the windows is in the wrong place, then the test has already failed. Hasn't it?

Regards,
Mateusz
Read only

0 Likes
2,725

I think it's just a useless test, as I said. But anyway, no tool exists (except the one mentioned by Frederic), so I think the only valid answer for this question is currently that it would cost too much to do this kind of test compared to the gain.

My two cents is that the only affordable test is the invoking of the smart form with given input parameters and verify portions of the OTF output. That's quite easy to do (but of course, the smart form should be written such a way to not contain ABAP code with dependencies, all external data used by the smart form should be passed via parameters, otherwise the cost increases).

Read only

Sandra_Rossi
Active Contributor
0 Likes
2,725

My answer is the same as previous one.

Otherwise, doing it manually is the cheapest solution.

There is another (non SAP) solution, to do a comparison by image, but I don't know what tools exist, how they work and how they can be integrated with SAP.

Read only

Sandra_Rossi
Active Contributor
0 Likes
2,725

frdric.girod The OTF output also shows the positions, not only the texts. And also frames, colors, fonts and so on (but it may still differ from the final rendering...) OTF is a very simple format, it's easy to analyze.