Skip to Content
Technical Articles

Visualize test coverage in Integrationtests

The problem

Recently i had to deal with testing a company merge. It was decided to introduce business areas. The business areas were assigned to a plant and a devision. Every financial document needed now a business area.

Directed tests

In this step we thought about what different kind of documents need to be considered. Let’s take for example incoming invoices for purchase orders. Purchase orders have different characteristics. A few are listed below:

  1. Order type
  2. without, with single or with multiple account assignments
  3. account assignment category (cost center, asset, sales order, …)
  4. with or without material
  5. Material master data contains devision or not

Different types of invoices are possible:

  1. Invoice with or without price deduction
  2. Credit memo
  3. Invoice for freight and other purchase costs

This huge amount of test-cases made coverage tracking necessary.

The solution

The data model of financial and their associated documents has one big advantage. Every document has a unique number. So after setting up the customizing and before starting the test, we captured the number ranges from table NRIV and stored them persistently in table ZNRIV. We knew, if a document was booked before the business areas were introduced or afterwards.

Tracking coverage

For tracking and visualizing we wrote small queries, which showed the characteristics of the created documents. The query for purchase order characteristics:


SELECT nrrangenr, nrlevel FROM znriv INTO TABLE number_ranges_from
  WHERE object = 'EINKBELEG'.
  SELECT h~ebeln, i~ebelp, h~bsart, i~knttp, m~spart, i~matnr, d~vgabe, d~belnr, d~gjahr, h~bukrs
    FROM ekko AS h INNER JOIN t161 AS nr ON nr~bstyp = h~bstyp AND nr~bsart = h~bsart
    INNER JOIN ekpo AS i ON h~ebeln = i~ebeln
    LEFT OUTER JOIN mara AS m ON m~matnr = i~matnr
    INNER JOIN ekbe AS d ON d~ebeln = i~ebeln AND d~ebelp = i~ebelp
    FOR ALL ENTRIES IN @number_ranges_from
    WHERE d~vgabe IN ('2', '3')
    AND nr~numki = @number_ranges_from-nrrangenr AND h~ebeln > @number_ranges_from-nrlevel
    INTO TABLE @DATA(actual_coverage).
  SORT actual_coverage BY bsart knttp spart matnr ebeln ebelp vgabe.
  cl_demo_output=>write( actual_coverage ).

  reference_keys = VALUE #( FOR invoice IN actual_coverage
    ( awkey = |{ invoice-belnr }{ invoice-gjahr }| bukrs = invoice-bukrs ) ).
  SELECT bukrs, belnr, gjahr, awkey FROM bkpf
    FOR ALL ENTRIES IN @reference_keys
    WHERE awtyp = 'RMRP' AND bukrs = @reference_keys-bukrs AND awkey = @reference_keys-awkey
    INTO TABLE @DATA(booking_keys).
  SELECT bukrs, belnr, gjahr, buzei, bschl, hkont, gsber, ebeln, ebelp FROM bseg
    FOR ALL ENTRIES IN  @booking_keys
    WHERE bukrs = @booking_keys-bukrs AND belnr = @booking_keys-belnr AND gjahr = @booking_keys-gjahr
    INTO TABLE @DATA(test_results).
  cl_demo_output=>write( test_results ).
  cl_demo_output=>display( ).

Evaluating these queries gave us a fine control over the actual test coverage and they were useful to analyze the characteristics of the existing documents.

Be the first to leave a comment
You must be Logged on to comment or reply to a post.