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

ABAP Units test environment class CL_FUNCTION_TEST_ENVIRONMENT/If_FUNCTION_TEST_ENVIRONMENT does not

abhishek_nag
Explorer
0 Likes
3,116

Hi All,

We are in S4 HANA Private 2020. And I am working on Aunits. And I see all environment classes except CL_FUNCTION_TEST_ENVIRONMENT/If_FUNCTION_TEST_ENVIRONMENT. This does not exist

What could be the reason and what should we do.

9 REPLIES 9
Read only

Sandra_Rossi
Active Contributor
3,062

Either upgrade to a more recent version, or mock CALL FUNCTION '...' as usual (dao->call_function->name or whatever, DAO productive by default, switch to test when running ABAP Unit, via dependency lookup or whatever).

Read only

0 Likes
3,022

The Function Module is to update the Bank Master. If I do not do double, then it will create Bank in SAP in Local test environment. Secondly what is DAO & Via dependency look up

Read only

0 Likes
3,012

In short, it's a mock, by default it's the productive mode (calls the function module), but with ABAP Unit you inject another behavior. Your DAO instance is based on an interface with two implementations, one for productive use and one for test. DAO and dependency lookup are part of automatic unit tests and are explained anywhere in the Web (not limited to SAP).

Read only

0 Likes
3,011

ok. Let me call the FM in test class and see 

Read only

0 Likes
2,999

If I just call the BAPI with doubles , its creating data in SAP . I do not want any update in Local test class

Read only

0 Likes
2,997

I am sorry. One correction. 

If I just call the BAPI without doubles , its creating data in SAP . I do not want any update in Local test class

 

Read only

0 Likes
2,984

No. For the test mode, don't call the FM.

Read only

0 Likes
2,983

I don't get it. This BAPI call is wrapped in a method. And I am testing this method in my LTC. How can I remove BAPI. So let's put it simple. I want to test 1 method that has BAPI call. Can I test this method without doubles

Read only

0 Likes
2,661

The basic idea is to replace all external calls like the call of a Function module by mocks. So the productive code will call a class which implements the BAPI call in a method via an interface and the unit test calls a mock class sharing the same interface, does nothing, but returning the expected / desired value. Maybe a bit old but in my opinion still worth. 
Especially if you do not have the testdoubles in your system. 
Writing Testable Code for ABAP (sap.com)