Automating ABAP Unit Test Runs with the Code Inspector
Here’s a tip for those of you out there who are responsible for quality testing using ABAP Unit module tests. You can automate ABAP Unit runs with the ABAP Code Inspector as of Release NW04 (6.40).
Let me explain why this is a useful tip. For most quality advocates, the first task is to get your developers to implement ABAP Unit tests.
But once you have ABAP Unit tests in place, then a second, problematic task emerges: Running the ABAP Unit tests regularly. After all, you created the unit tests because you wanted to detect problems introduced into existing functions by changes in coding, and you wanted to be able to verify that new coding works as designed.
To achieve these desirable results, you need to run a perhaps quite large set of unit tests more or less regularly, when code arrives in your test system. It is a bit tedious, however, to travel through the relevant classes, function groups, programs in the ABAP Object Navigator calling Test -> Unit Test off the context menu at each stop.
Fortunately the Code Inspector of the ABAP Workbench provides a convenient way for you to automate executions – and even track results – of selected sets of ABAP Unit tests. Here is how to do this:
Start the Code Inspector (transaction SCI) in your testing system.
Pick out the ABAP classes, programs, and function groups whose unit tests are to run under this object set.
Ideally, you can just specify the set of packages in which you are actively developing. Leave Save Selections Only on to select objects according to object assignments fresh every time that you use the object set.
When you are ready, save the object set and return to the SCI start screen.
- Create a check variant.
- Mark only the Dynamic Tests option on the Check Variant screen. Then save your check variant and return to the SCI start screen.
- Now you can create an inspection that uses the object set and check variant that you just created.
- The Execute button with … opens a window in which you decide how to run the inspection. As the screen shot shows, set the inspection to run as a background job. Whenever the job runs, all of the ABAP Unit tests in the object set will be run. The Code Inspector saves the results of each run.
All of the repetition features of ABAP background processing are available to you – but if you import code on a regular schedule, then you probably need only schedule the job periodically.
Here, the ABAP Units inspection is scheduled to run immediately as a background job and will be repeated weekly.
- A finished inspection is marked with a green icon, as you can see here. Clicking on Possible Entries (F4) in the Inspection field shows you the status of the current and past inspections. Click on an inspection to open it.
Then click on the Results button to see any messages issued by the ABAP Unit tests.