2023 Aug 25 4:36 AM
Hi experts,
In local class definition.
CLASS ltd_mock_aa DEFINITION CREATE PUBLIC FINAL FOR TESTING.
ENDCLASS.
I am wondering what the use of "FOR TESTING" is, thank you.
Regards,
Eric
2023 Aug 25 6:04 AM
Did you search?
see SAP official documentation -> ABAP -> ABAP Unit
2023 Aug 25 6:16 AM
There are two local class files, "Local Test Classes" and "Local Definition/Implementations".
I found some classes defined in "Local Definition/Implementations" are marked as "FOR TESTING" and I don't get it. I think it is meaningless.
2023 Aug 25 6:49 AM
We don't know your code. If it's standard, please indicate the name of the object so that people can have a look at it.
If this class is called and used for testing, it is MEANINGFUL.
But I agree, I always define the local test classes in the section of local test classes, so I'm a little surprised to see one defined in the section of local definition/implementations, and also surprised that it compiles. Maybe there's a reason that SAP permits that, and maybe that in fact it's the core of your question.
NB: I don't know why.
2023 Aug 25 7:36 AM
A class pool is made up for includes. The includes from Local Definition, Local Implementation, Local Test Classes are at the bottom. They can be in any order. That's why you can define test classes in Local Definition.
Essentially what you've found is bad programming practice.
2023 Aug 25 7:40 AM