‎2024 Oct 22 9:33 PM
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.
‎2024 Oct 23 5:54 AM
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).
‎2024 Oct 23 2:53 PM
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
‎2024 Oct 23 4:14 PM
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).
‎2024 Oct 23 4:18 PM
ok. Let me call the FM in test class and see
‎2024 Oct 23 4:32 PM
If I just call the BAPI with doubles , its creating data in SAP . I do not want any update in Local test class
‎2024 Oct 23 4:34 PM
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
‎2024 Oct 23 5:00 PM
No. For the test mode, don't call the FM.
‎2024 Oct 23 5:42 PM
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
‎2024 Nov 15 2:00 PM
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)