Skip to content

Name the code under test meaningfully, or default to CUT

Give the variable that represents the code under test a meaningful name:

DATA blog_post TYPE REF TO ...

Don’t just repeat the class name with all its non-valuable namespaces and prefixes:

" anti-pattern
DATA clean_fra_blog_post TYPE REF TO ...

If you have different test setups, it can be helpful to describe the object’s varying state:

DATA empty_blog_post TYPE REF TO ...
DATA simple_blog_post TYPE REF TO ...
DATA very_long_blog_post TYPE REF TO ...

If you have problems finding a meaningful name, resort to cut as a default. The abbreviation stands for “code under test”.

DATA cut TYPE REF TO ...

Especially in unclean and confusing tests, calling the variable cut can temporarily help the reader see what’s actually tested. However, tidying up the tests is the actual way to go for the long run.

From SAP/styleguides under CC BY 3.0 — more details
Last updated on