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

How to unit test ALV based GUI components

2,691

Hi Community,

i want to add unit tests to my GUI components (most ALV based) but i do not have any clue how to.

Basic structure of all classes which are responsible for (ALV) GUI handling

* generate ALV (public) -> Build ALV and display
* refresh ALV (protected / event) -> refresh ALV if surrounding GUI component notifies via event
* handle_click (private) -> handle component specific events like button clicks etc.

Are there any suggestion to unit test such objects. Code to cover is mostly within private methods for component specific events.

Thx Sebastian

7 REPLIES 7
Read only

RobertVit
Active Contributor
0 Likes
1,977

Hi Sebastian,

for UI testing i would go for eCATT.

Kind regards
Robert
Read only

0 Likes
1,977

Hi Robert,

i do not want to test the UI. Goal is to have the code behind covered by unit tests.

Are there any other approaches?

Thx

Read only

UweFetzer_se38
Active Contributor
1,977

In my opinion you only have to test the content of the table and the behaviour of the events.

  • test the methods, in which the content is created
  • extract the event methods (click) into separate methods and test only them
Read only

0 Likes
1,977

Hi Uwe,

that's clear but how to testdouble a necessary gui container which is required for code under test.
I didn't find a way to mock any object based on CL_GUI_CONTAINER (or inherited)

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,977

I didn't find a way to mock any object based on CL_GUI_CONTAINER (or inherited)

Been there & tried that without any success. But then again, why do you want to mock the control framework?

I agree with se38 on this one, i would test the contents of the output table & the event handling logic (if any).

Read only

1,977

To clarify: maybe your design does not allow unit tests. All the logic should be placed in its own class which you can test. The UI just calls these tested methods.

Read only

matt
Active Contributor
0 Likes
1,977

Create an interface with all the methods that you'll be using in the CL_GUI class. Implement it with pass through calls to the actual CL_GUI class. Create a local test double implementing the interface.

Inject a reference to the local test double.