Skip to Content
Technical Articles
Author's profile photo Michael Gutfleisch

ABAP Unit Test Relations

Hi ADT community,

this time we have prepared a video about ABAP Unit, and especially about Test Relations.

You can use ABAP Unit to easily write automated tests for your repository objects, particularly if the production code you want to test is contained in a class pool, function pool or report. These object types are the only ones that can contain test code and therefore we call them test containers.

Other object types, like DDL sources or simple transformations cannot contain any test code. If you want to test a CDS view contained in a DDL source you have to use another repository object (a test container) and write the tests for the CDS view there.

This works fine, but there is one issue: the test code is not related to the production code. Therefore it is difficult to find the relevant tests for a certain object and execute them. To solve this issue, a relation between a test and a piece of production code has to be modeled. To model this connection, you can write a specific @testing link as ABAP doc comment in front of the test method or test class.

With such a test relation in place, you can now trigger unit test execution directly from the tested object and ADT will find and execute all related tests.

The following video tells a story about a customer having a problem with test relations and it explains how the feature is used correctly.

 

 

After watching the video it is time to try out test relations for your own objects. Maybe you have not yet linked your tests to a certain CDS View or you want to link your integration tests to the tested classes. Now it’s time to do so!

Or you just want to try the ABAP Unit Dialog (Ctrl+Shift+F12) with the ABAP Unit Preview feature.

Here are some links to the documentation:

 

I hope you enjoy the ABAP Unit Tools in ADT,
Michael

Assigned tags

      3 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Robert Forster
      Robert Forster

      Awesome video

      The interactive documentation (map) is realy great

      Author's profile photo Peter Landwehr
      Peter Landwehr

      Hi Michael, really, really cool. I know that's a repeat of the comment above but I felt obliged to give it. It really feels like Christmas 🙂

      Author's profile photo Maximilian Malz
      Maximilian Malz

      Thanks, I'm learning TDD in ABAP. This Video helped me with the annoying Warning I just couldn't solve.. I forgot the first Line:
      "! @testing NAME_OF_THE_CLASS_I_WANT_TO_TEST
      (because I didn't know this line had to be there in the first place)