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

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

EricYu0912
Product and Topic Expert
Product and Topic Expert
793

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
Read only

Sandra_Rossi
Active Contributor
0 Kudos
729

Did you search?

see SAP official documentation -> ABAP -> ABAP Unit

Read only

EricYu0912
Product and Topic Expert
Product and Topic Expert
0 Kudos
729

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.

Read only

Sandra_Rossi
Active Contributor
729

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.

Read only

matt
Active Contributor
729

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.

Read only

EricYu0912
Product and Topic Expert
Product and Topic Expert
0 Kudos
729

Thanks for the answer.