This is a test message to test the length of the message box.
Login
ABAP Tools Work with Eclipse
Created by Software-Heroes

ABAP Tools - Quick Actions und Highlighting (ABAP Unit)

1335

With the last release of the ABAP Development Tools, Quick Actions were added for ABAP development in the ABAP Unit area. Here we take a closer look at them.



In this article we will look at the new quick actions and code highlighting in the ABAP Unit area. Some features are currently only offered in the ABAP Environment in the BTP, but will certainly be downported to On-Premise in the future.

 

Introduction

In the ABAP Development Tools Release 3.42, the quick actions were introduced in the ABAP Unit area. These actions are intended to take some of the work off your hands when writing unit tests and make you faster as a developer. Quick Actions are usually icons or buttons integrated into the code that trigger further actions related to the current line or selection.

 

Preparation

First of all, we need a small class with which we can demonstrate the various options. To do this, we define a simple class with two public methods.

CLASS zcl_bs_demo_quick_actions DEFINITION
  PUBLIC FINAL
  CREATE PUBLIC.

  PUBLIC SECTION.
    METHODS concatenate_string
      IMPORTING id_text1         TYPE string
                id_text2         TYPE string
      RETURNING VALUE(rd_result) TYPE string.

    METHODS adding_numbers
      IMPORTING id_number1       TYPE i
                id_number2       TYPE i
      RETURNING VALUE(rd_result) TYPE string.
ENDCLASS.


CLASS zcl_bs_demo_quick_actions IMPLEMENTATION.
  METHOD concatenate_string.
    rd_result = id_text1 && id_text2.
  ENDMETHOD.


  METHOD adding_numbers.
    rd_result = id_number1 + id_number2.
  ENDMETHOD.
ENDCLASS.

 

The first method joins two strings and the second method calculates the sum of two numbers. We will use both methods for our tests.

 

Quick Actions

In the first step, let's look at the Quick Actions, how you configure them and how you can use them for yourself.

 

Configuration

You can find the Quick Actions in the general settings in the menu under "Window -> Preferences", then in the dialog under the tree "ABAP Development -> ABAP Unit -> Code Minings".

 

There you can activate various options; in our example we activate all functions. In order for the functions to take effect, you should restart Eclipse.

 

Create test

Let's now switch to the "Test Classes" tab to get to the test classes area, where our test cases are usually defined. You will already find the first action there.

 

If you click on the action, the corresponding test coding is created; this corresponds to the corresponding templates from Eclipse. In the future, suitable test methods for our public methods could be defined here using AI, for example. The result now looks like this.

 

In the next step, we implement two test cases to have some test coding. The first test case will run on green (successful) and the second on red (faulty). The corresponding implementation of the test class is as follows:

CLASS ltc_my_unit_test DEFINITION FINAL
  FOR TESTING RISK LEVEL HARMLESS DURATION SHORT.

  PRIVATE SECTION.
    METHODS run_mathematics FOR TESTING.
    METHODS run_strings     FOR TESTING.
ENDCLASS.


CLASS ltc_my_unit_test IMPLEMENTATION.
  METHOD run_mathematics.
    DATA(lo_cut) = NEW zcl_bs_demo_quick_actions( ).

    DATA(ld_result) = lo_cut->adding_numbers( id_number1 = 10
                                              id_number2 = 5 ).

    cl_abap_unit_assert=>assert_equals( exp = 15
                                        act = ld_result ).
  ENDMETHOD.

  METHOD run_strings.
    DATA(lo_cut) = NEW zcl_bs_demo_quick_actions( ).

    DATA(ld_result) = lo_cut->concatenate_string( id_text1 = `Hello`
                                                  id_text2 = `ABAP Unit` ).

    cl_abap_unit_assert=>assert_equals( exp = `Hello ABAP Unit`
                                        act = ld_result ).
  ENDMETHOD.
ENDCLASS.

 

Execute test

Now that we have activated the coding, the next quick actions appear, depending on what you chose during configuration.

 

We can now execute individual test cases or the entire test class using the various "Run" buttons. In the first example, we only execute the RUN_MATHEMATICS method and the result is displayed directly in the source code.

 

You can find the status and runtime on the method, and the number of test cases executed and the overall status on the test class. As a second test case, we now execute all test cases in the test class. The corresponding status can now be viewed.

 

You can then basically start fixing the bug in the method and execute it until the result is correct. This means that all methods do not have to be executed each time to validate the delta.

 

Highlighting

The second function in this article covers code highlighting in ABAP Unit.

 

Configuration

You can find the configuration in the general settings in the menu under "Window -> Preferences", then in the dialog under the tree "ABAP Development -> ABAP Unit -> Test Code Highlighting".

 

Here you can activate the various settings again and later you will have the option of setting the colors for the individual options.

 

Display

What effects do the settings have? You have already seen the effects above and here is the screenshot again.

 

The individual components of your test code are now highlighted in color, depending on the object. If you move the mouse over the highlighted block, you will receive information about it.

 

Conclusion

This means that you now have two additional functions available in the ADTs to quickly and easily write and execute unit tests and analyze the test code. The functions certainly have potential for further AI features in the future.

 

Source:

SAP Help - How to Write ABAP Unit Tests


Included topics:
ToolsADTEclipseQuick Actions
Comments (0)



And further ...

Are you satisfied with the content of the article? We post new content in the ABAP area every Tuesday and Friday and irregularly in all other areas. Take a look at our tools and apps, we provide them free of charge.


ABAP Tools - IDE Actions (Value Help)

Category - ABAP

Let's take a detailed look at how we can create a value help for our input for our IDE action in ADT. We'll examine several possibilities and dependencies.

11/11/2025

ABAP Tools - IDE Actions (Input)

Category - ABAP

How can we retrieve information before the actual IDE action is executed in ABAP? Let's implement the first version of a simple input.

11/04/2025

ABAP Tools - IDE Actions (Output)

Category - ABAP

Let's look at the output options we currently have with IDE Actions and what we can achieve with them. We will look at different implementation examples for each case.

10/28/2025

ABAP Tools - IDE Actions (Creation)

Category - ABAP

Let's create our first IDE action for the ABAP Development Tools together. We'll guide you step by step through the process and the interfaces.

10/24/2025

ABAP Tools - IDE Actions (Introduction)

Category - ABAP

Let's take a look at the basics and a brief introduction to IDE Actions. We'll cover availability and other important details you should know as an ABAP developer.

10/21/2025