This is a test message to test the length of the message box.
Login
|
ABAP Cloud Test Data Container
Created by Software-Heroes

ABAP Cloud - Test Data Container

1051

Test data containers aren't released for ABAP Cloud, so how can generic test data be accessed? Here's a suggested simple framework.

Advertising


In this article, we want to introduce you to the open source project for test data containers. We will discuss their structure and use, and show you other possibilities. The idea arose in a discussion with Frank Engert.

 

Introduction

Test data containers are used for testing in the SAP system. This allows you to easily store and maintain generic data without having to adapt the actual unit test later. If you'd like to learn more about the classic usage, there's an article in the SAP Community. However, the containers have not been released for ABAP Cloud because there is no suitable front end for maintaining the data. Currently, all test data would have to be maintained in the test case, which makes it somewhat cumbersome and confusing.

 

Architecture

The architecture of the component is kept relatively simple, and we reuse some standards. The idea is to use an external editor to maintain the data in structured formats and to utilize the formatting options available in those editors. For example, GitHub's JSON editor takes over the validation and formatting of the content, similar to the maintenance in the SAP GUI. We can then retrieve the file from GitHub via the HTTP protocol and use it in our tests. The formats JSON, abapXML, and RAW are currently supported.

 

 

Hint: Currently, only ABAP Cloud in the public cloud is supported, as we use the new HTTP Client to establish an internet connection.

 

Maintenance

Data maintenance takes place outside of ABAP. In this example, we use the integrated IDE in GitHub to maintain the data. In the example, for example, a comma is missing; the editor highlights the corresponding location so that we receive support in maintaining the data and provide a correct format.

 

Usage

In this chapter, we will look at its use for unit tests and within the logic. To read the data, we use the 

 

Configuration

A configuration represents an access path and the reading routine for it. Currently, there is only the configuration for GitHub; you can find this in the class ZCL_TDC_GITHUB_CONFIG. We create a new configuration by passing the path to the file to the constructor.

DATA(configuration) = NEW zcl_tdc_github_config( test_file_path ).

 

The path to the raw file is required to load the file. If you view the file on GitHub, there is a button in the right corner that loads the file in the appropriate view. We will use this path as the source for the configuration.

 

Container

In the next step, we create a container to access the file. To do this, we pass the configuration to the factory method and receive the container back for use.

DATA(container) = zcl_test_container_factory=>create( configuration ).

 

The container offers us various methods for accessing the data. There are two methods for obtaining the file contents in RAW format: as a string or as an XString. Using the other two methods, we can populate our table or structure; the corresponding parsers are included in the methods.

 

Data

If we now want to load the data, we need a structure or table to which we can map the data. To do this, we define a local type that has the same format as the JSON file.

TYPES: BEGIN OF github_test,
         text    TYPE string,
         number  TYPE i,
         boolean TYPE abap_bool,
       END OF github_test.
TYPES github_tests TYPE STANDARD TABLE OF github_test WITH EMPTY KEY.

 

To read the data and fill it into the structure, we just need to call the corresponding method. In this case, we read the data as JSON. In the background, the HTTP client is used to load the data live from GitHub.

container->get_json_data( CHANGING generic = result ).

 

Examples

You can find further examples of using the test data container in the unit tests of the class ZCL_TEST_CONTAINER. All methods are used there with examples from the repository and you can find further information on creating the structure.

 

GitHub

You can find the complete open source project for the test data container in our GitHub repository. You can use the project freely.

 

Conclusion

You can use this small framework to manage complex data via an external platform and utilize the capabilities of other editors for maintenance. However, you generally have a dependency on the component, for example, if the internet is down. Ultimately, however, you can also use the container to make data available for processing, as the framework is not limited to unit tests.


Included topics:
ABAP CloudABAPTest Data Container
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 Cloud - Hashes

Category - ABAP

Do you want to create a hash in ABAP Cloud? Which classes are available for this purpose, and how can you use them effectively?

03/03/2026

ABAP Cloud - SM30 Migration

Category - ABAP

In this tutorial, we'll look at migrating a maintenance view to ABAP Cloud and how to migrate existing objects step by step. We'll examine various aspects of the new maintenance application.

02/27/2026

ABAP Cloud - Custom Unit

Category - ABAP

In this article, we will look at how we can define our own units in the system and then connect them to our RAP application.

02/06/2026

ABAP Quick - Logging Performance

Category - ABAP

What about the performance of the BAL log in the ABAP Cloud world? Let's look at three solutions and measure their performance in different scenarios.

12/19/2025

ABAP Cloud - Access to Components

Category - ABAP

What exactly is ABAP Cloud's approach to accessing components? In this article, we'll look at the different levels and what we can do with the information.

10/18/2025