‎2019 Jul 11 11:04 PM
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
‎2019 Jul 12 8:14 AM
Hi Sebastian,
for UI testing i would go for eCATT.
‎2019 Jul 12 9:22 AM
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
‎2019 Jul 16 2:12 PM
In my opinion you only have to test the content of the table and the behaviour of the events.
‎2019 Jul 17 9:45 AM
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)
‎2019 Jul 17 10:05 AM
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).
‎2019 Jul 17 2:31 PM
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.
‎2019 Jul 17 3:47 PM
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.