Application Development 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: 

What is the use of "FOR TESTING" in local class?

phoenixming0912
Product and Topic Expert
Product and Topic Expert

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

5 REPLIES 5

Sandra_Rossi
Active Contributor
0 Kudos

Did you search?

see SAP official documentation -> ABAP -> ABAP Unit

phoenixming0912
Product and Topic Expert
Product and Topic Expert
0 Kudos

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.

Sandra_Rossi
Active Contributor

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.

matt
Active Contributor

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.

phoenixming0912
Product and Topic Expert
Product and Topic Expert
0 Kudos

Thanks for the answer.