Skip to content

Latest commit

 

History

History
128 lines (91 loc) · 3.74 KB

aunit.md

File metadata and controls

128 lines (91 loc) · 3.74 KB

ABAP Unit

  1. run

run

Execute sapcli with the parameters aunit run OBJECT_TYPE OBJECT_NAME [OBJECT_NAME | ...].

Supported object types (OBJECT_TYPE):

  • package
  • class
  • program
  • program-include
  • transport

The exit code will be determined based on test results where exit code is the number of failed and erroed tests if unit included in the result.

sapcli aunit run {package,class,program,program-include,transport} NAME [--output {raw,human,junit4}] [--as4user NAME] [--result {unit,coverage,all}] [--coverage-output {raw, human, jacoco}] [--coverage-filepath PATH]
  • transport : if you use transport, NAME is Transport Number
  • program-include: sapcli will try to automatically determine the corresponding main program. If it cannot be done, it is possible to define the main program by prepending the main program's name to the parameter NAME the following way: "MAIN_PROGRAM_NAME\NAME" (concatenate the main program's name with the include's name and use back slash as separator).
  • --as4user : used only for transports to be able to select the transport
  • --result: desired result to be displayed
  • --coverage-filepath: path where coverage output will be stored if one of coverage or all is selected as result

If you struggle to get Transport User, you can use datapreview:

sapcli datapreview osql --noheadings "SELECT as4user FROM e070 WHERE trkorr EQ '$CORRNR'"

Output format

Raw

Tests results are printed in the form as they were returned from ADT.

Human

This format attempts to provide nice human readable form of the test results.

GLOBAL PUBLIC CLASS FOO
  LOCAL TEST CLASS A
    TEST METHOD1 [SUCCESS]
  LOCAL TEST CLASS B
    TEST METHOD1 [ERROR]
GLOBAL PUBLIC CLASS FOO
  LOCAL TEST CLASS A
    TEST METHOD1 [SKIPPED]
  LOCAL TEST CLASS B
    TEST METHOD1 [SUCCESS]

GLOBAL PUBLIC CLASS FOO=>LOCAL TEST CLASS A=>TEST METHOD1
* [critical] [failedAssertion] Assertion failed

Succeeded: 2
Skipped:   1
Failed:    1

JUnit

The JUnit format was assembled from:

  • testsuites

    • name: CLASS NAME | PROGRAM NAME | PACKAGE NAME
  • testsuite

    • name: testClass[name]
    • package: CLASS NAME | PROGRAM NAME
  • testcase

    • name: testMethod[name]
    • skipped: alert[kind]
    • system-err: alert/details
  • error: alert

    • message: title
    • type: kind
    • text = alert/stack

Sonar

Test results are printed in the Sonar "Generic Execution" format as defined in:

If the code was previously checked, an attempt is made to match up the test classes with their corresponding files:

sapcli checkout package {packagename}
sapcli aunit run package {packagename} --output sonar

If the command is run without checking out the code, or if no matching test class can be found, a synthentic path is used with the format PACKAGE-NAME/CLASS-NAME=>TEST-CLASS-NAME.

Alerts generated for the test class are represented as a testCase with the name property set to the name of the test class.

Coverage output format

Raw

Coverage results are printed in the form as they were returned from ADT.

Human

This format attempts to provide nice human readable form of the coverage results.

PACKAGE FOO : 31.19%
  CLASS BAR : 95.52%
    METHOD A : 100.00%
    METHOD B : 75.00%
    METHOD C : 100.00%

JaCoCo

Coverage results are printed in the JaCoCo format as defined in: