Skip to Content
Author's profile photo Former Member

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:

  1. Start the Code Inspector (transaction SCI) in your testing system.
  2. Create an object set that specifies what ABAP Unit tests are to be run.

    Create an Object Set

  3. 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.

    Select the Objects Whose Unit Tess Should Run

    When you are ready, save the object set and return to the SCI start screen.

  4. Create a check variant.

    Create a Check Variant

  5. Mark only the Dynamic Tests option on the Check Variant screen.  Then save your check variant and return to the SCI start screen.

    Mark Dynamic Tests

  6. Now you can create an inspection that uses the object set and check variant that you just created.

    Create an Inspection

    Run the Inspection with Execute...

  7. 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.

    Schedule the Inspection to Run as a Job

    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.

    Choose Periodic Execution for the Batch Job

  8. 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.

    Choose from the Available Results

    Then click on the Results button to see any messages issued by the ABAP Unit tests.

    Finally - The ABAP Unit Results

Assigned Tags

      3 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Horst Keller
      Horst Keller
      Hi Stephen,

      thanks for this great block on automated testing. Working with Releases higher than 7.01 at SAP itself, one often forgets that customers do not have hands on  ABAP Unit Browser in SE80 or ABAP Test Cockpit (ATC) yet. Therefore it's good that you explained how to do it in Code Inspector.

      Cheers!

      Horst

      Author's profile photo Matthew Billingham
      Matthew Billingham
      This blog just got a nice plug at Teched Vienna, by Thomas Ritter.
      Author's profile photo Mohamed Ismail
      Mohamed Ismail
      It is useful information.

      Regards,
      Jaheer