2023 Jun 20 10:15 PM
Hi,
I'm quite new in ABAP and see a lot of ABAP methods or FMs with ABAP select statements reading data from the tables.
When it comes to testing and especially unit tests, it's almost impossible to write such a unit test, since the data coming from the tables is volatile and will change.
Somehow it can be achieved with test double framework. But database mocks are not possible, since we are still on
on ECC 7.5 and osql test double framework does not exist.
Question:
Is it still a good practice to have all these select statements directly in the methods or FMs, or would it be recommended to create something like a repository class with an interface to encapsulate the data access logic.
The idea then is to use the normal test double framework and create a mock object of the repository object for the unit tests.
Thank your very much for the ideas, answers and maybe experiences.
2023 Jun 21 6:04 AM
And a dedicated class for data will help you to create a mock and test class using this data class
2023 Jun 21 9:39 PM
Looks a bit like coming from ChatGPT 😉
Anyway, I know all the advantages and disadvantages, since in the Non-ABAP world it's very common.
But then I see any ABAP code, even SAP standard, I cannot see patterns like that. So my question goes more in the direction of:
Is it also in SAP - ABAP common practice to encapsulate data access?
Is it common to write Unit Tests especially create mock objects?
Thanks a lot.