Monday, May 18, 2015

SAP Unit Tests actually exist, report of a sighting

One of most impressive things in SAP, and impressive in a bad way, is the huge effort of people executing tests to validate the software after upgrades or some larger developments. It should not be like this. We now look back and we think it is funny a room full of people performing calculations like in this picture from the 40s.

But almost 100 years later this is more or less how a SAP upgrade is tested.

The reason is historic. The "old" SAP code is large, monolithic and highly integrated (a nicer way to describe a crazy web of dependencies). Not surprisingly this older code comes without automated tests, these would be hard to implement in such architecture. But not all SAP is coded the same way. Components developed in the last 10-15 years follow the typical object-oriented modular software best practices. And SAP also includes a complete framework for unit tests. My expectation was that SAP would start shipping more and more unit tests, and this would help reduce the need of manual testing and reduce the risk of regressions when installing SAP updates.

So for many years I asked myself: Where are the SAP unit tests???

Many times I tried the option to see the unit tests in SAP objects, just to find out ... there was none.

Anyone remembers something similar? This documentation option in functions. At least the experience is consistent, it almost never shows any documentation.

It actually shows a message to make you feel there could be something in other language. But, of course, there was nothing.

But now I finally saw some unit tests in SAP code. It was in /SAPAPO/CL_ALL_LOCK_DELTA class (in SAP SCM software).

So unit tests exists, it is worth searching for them. Looking at the unit tests is also a good way to understand how to use that part of the code.

And now I have some SAP example to show when trying to bring unit testing best practices to the custom developments world. SAP recommends using unit tests. You know those words can take you a long way.