Skip to content

abapEnvironmentRunAUnitTest

Runs an AUnit Test

Description

This step is for triggering an AUnit test run on an SAP BTP ABAP Environment system. Please provide either of the following options:

  • The host and credentials of the BTP ABAP Environment system itself. The credentials must be configured for the Communication Scenario SAP_COM_0735.
  • The Cloud Foundry parameters (API endpoint, organization, space), credentials, the service instance for the ABAP service and the service key for the Communication Scenario SAP_COM_0735.
  • Only provide one of those options with the respective credentials. If all values are provided, the direct communication (via host) has priority.

Regardless of the option you chose, please make sure to provide the object set containing the objects that you want to be checked analog to the examples listed on this page.

Usage

We recommend to define values of step parameters via .pipeline/config.yml file.
In this case, calling the step is essentially reduced to defining the step name.
Calling the step can be done either in an orchestrator specific way (e.g. via a Jenkins library step) or on the command line.

library('piper-lib-os')

abapEnvironmentRunAUnitTest script: this
piper abapEnvironmentRunAUnitTest

!!! Currently the Object Set configuration is limited to the usage of Multi Property Sets. Please note that other sets besides the Multi Property Set will not be included in the ABAP Unit test runs. You can see an example of the Multi Property Sets with all configurable properties. However, we strongly reccommend to only specify packages and software components like in the first two examples of the section AUnit config file example.

Prerequisites

  • A SAP BTP, ABAP environment system is available. On this system, a Communication User, a Communication System and a Communication Arrangement is setup for the Communication Scenario “SAP BTP, ABAP Environment - Software Component Test Integration (SAP_COM_0735)“. This can be done manually through the respective applications on the SAP BTP, ABAP environment system or through creating a Service Key for the system on Cloud Foundry with the parameters {“scenario_id”: “SAP_COM_0735", “type”: “basic”}. In a pipeline, you can do this with the step cloudFoundryCreateServiceKey.
  • You can either provide the ABAP endpoint configuration to directly trigger an AUnit run on the ABAP system or optionally provide the Cloud Foundry parameters with your credentials to read a Service Key of a SAP BTP, ABAP environment system in Cloud Foundry that contains all the details of the ABAP endpoint to trigger an AUnit run.
  • Regardless if you chose an ABAP endpoint directly or reading a Cloud Foundry Service Key, you have to provide the object set containing the objects you want to be checked in an AUnit run in a .yml or .yaml file. This file must be stored in the same folder as the Jenkinsfile defining the pipeline.
  • Make sure that the objects contained in the object set are present in the configured system in order to run the check. Please make sure that you have created or pulled the respective software components and/or packages including the test classes and objects in the SAP BTP, ABAP environment system, that should be checked.

Parameters

Overview - Step

Name Mandatory Additional information
password (yes) Secret pass via ENV or Jenkins credentials (abapCredentialsId)
script (yes) Jenkins only reference to Jenkins main pipeline script
username (yes) Secret pass via ENV or Jenkins credentials (abapCredentialsId)
aUnitConfig no
aUnitResultsFileName no
cfApiEndpoint no
cfOrg no
cfServiceInstance no
cfServiceKeyName no
cfSpace no
generateHTML no
host no
repositories no
verbose no activates debug output

Overview - Execution Environment

Orchestrator-specific only

These parameters are relevant for orchestrator usage and not considered when using the command line option.

Name Mandatory Additional information
containerCommand no Jenkins only
containerShell no Jenkins only
dockerEnvVars no
dockerImage no
dockerName no
dockerOptions no
dockerPullImage no
dockerVolumeBind no Jenkins only
dockerWorkspace no Jenkins only

Details

aUnitConfig

Path to a YAML configuration file for the object set to be checked during the AUnit test run

back to overview

Scope Details
Aliases -
Type string
Mandatory no
Default $PIPER_aUnitConfig (if set)
Secret no
Configuration scope
  • ☒ parameter
  • ☐ general
  • ☒ steps
  • ☒ stages
Resource references none

aUnitResultsFileName

Specifies output file name for the results from the AUnit run.

back to overview

Scope Details
Aliases -
Type string
Mandatory no
Default AUnitResults.xml
Secret no
Configuration scope
  • ☒ parameter
  • ☐ general
  • ☒ steps
  • ☒ stages
Resource references none

cfApiEndpoint

Cloud Foundry API endpoint

back to overview

Scope Details
Aliases cloudFoundry/apiEndpoint
Type string
Mandatory no
Default $PIPER_cfApiEndpoint (if set)
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references none

cfOrg

Cloud Foundry org

back to overview

Scope Details
Aliases cloudFoundry/org
Type string
Mandatory no
Default $PIPER_cfOrg (if set)
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references none

cfServiceInstance

Parameter of ServiceInstance Name to delete Cloud Foundry Service

back to overview

Scope Details
Aliases cloudFoundry/serviceInstance
Type string
Mandatory no
Default $PIPER_cfServiceInstance (if set)
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references none

cfServiceKeyName

Parameter of Cloud Foundry Service Key to be created

back to overview

Scope Details
Aliases - cloudFoundry/serviceKey
- cloudFoundry/serviceKeyName
- cfServiceKey
Type string
Mandatory no
Default $PIPER_cfServiceKeyName (if set)
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references none

cfSpace

Cloud Foundry Space

back to overview

Scope Details
Aliases cloudFoundry/space
Type string
Mandatory no
Default $PIPER_cfSpace (if set)
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references none

containerCommand

Jenkins-specific: Used for proper environment setup.

Kubernetes only: Allows to specify start command for container created with dockerImage parameter to overwrite Piper default (/usr/bin/tail -f /dev/null).

back to overview

Scope Details
Aliases -
Type string
Mandatory no
Default
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references none

containerShell

Jenkins-specific: Used for proper environment setup.

Allows to specify the shell to be executed for container with containerName.

back to overview

Scope Details
Aliases -
Type string
Mandatory no
Default
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references none

dockerEnvVars

Jenkins-specific: Used for proper environment setup.

Environment variables to set in the container, e.g. [http_proxy: "proxy:8080"].

back to overview

Scope Details
Aliases -
Type map[string]string
Mandatory no
Default
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references none

dockerImage

Jenkins-specific: Used for proper environment setup.

Name of the docker image that should be used. If empty, Docker is not used and the command is executed directly on the Jenkins system.

back to overview

Scope Details
Aliases -
Type string
Mandatory no
Default ppiper/cf-cli:v12
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references none

dockerName

Jenkins-specific: Used for proper environment setup.

Kubernetes only: Name of the container launching dockerImage. SideCar only: Name of the container in local network.

back to overview

Scope Details
Aliases -
Type string
Mandatory no
Default cf
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references none

dockerOptions

Jenkins-specific: Used for proper environment setup.

Docker options to be set when starting the container.

back to overview

Scope Details
Aliases -
Type []string
Mandatory no
Default
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references none

dockerPullImage

Jenkins-specific: Used for proper environment setup.

Set this to 'false' to bypass a docker image pull. Useful during development process. Allows testing of images which are available in the local registry only.

back to overview

Scope Details
Aliases -
Type bool
Mandatory no
Default true
Possible values - true
- false
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references none

dockerVolumeBind

Jenkins-specific: Used for proper environment setup.

Volumes that should be mounted into the docker container.

back to overview

Scope Details
Aliases -
Type map[string]string
Mandatory no
Default
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references none

dockerWorkspace

Jenkins-specific: Used for proper environment setup.

Kubernetes only: Specifies a dedicated user home directory for the container which will be passed as value for environment variable HOME.

back to overview

Scope Details
Aliases -
Type string
Mandatory no
Default
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references none

generateHTML

Specifies whether the AUnit results should also be generated as an HTML document

back to overview

Scope Details
Aliases -
Type bool
Mandatory no
Default false
Possible values - true
- false
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references none

host

Specifies the host address of the SAP BTP ABAP Environment system

back to overview

Scope Details
Aliases -
Type string
Mandatory no
Default $PIPER_host (if set)
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references none

password

Password for either the Cloud Foundry API or the Communication Arrangement for SAP_COM_0735

back to overview

Scope Details
Aliases -
Type string
Mandatory yes
Default $PIPER_password (if set)
Secret yes
Configuration scope
  • ☒ parameter
  • ☐ general
  • ☒ steps
  • ☒ stages
Resource references Jenkins credential id:
  id: abapCredentialsId
  reference to: password

repositories

Specifies a YAML file containing the repositories configuration

back to overview

Scope Details
Aliases -
Type string
Mandatory no
Default $PIPER_repositories (if set)
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references none

script

Jenkins-specific: Used for proper environment setup.

The common script environment of the Jenkinsfile running. Typically the reference to the script calling the pipeline step is provided with the this parameter, as in script: this. This allows the function to access the commonPipelineEnvironment for retrieving, e.g. configuration parameters.

back to overview

Scope Details
Aliases -
Type Jenkins Script
Mandatory yes
Default
Secret no
Configuration scope
  • ☐ parameter
  • ☐ general
  • ☐ steps
  • ☐ stages
Resource references none

username

User for either the Cloud Foundry API or the Communication Arrangement for SAP_COM_0735

back to overview

Scope Details
Aliases -
Type string
Mandatory yes
Default $PIPER_username (if set)
Secret yes
Configuration scope
  • ☒ parameter
  • ☐ general
  • ☒ steps
  • ☒ stages
Resource references Jenkins credential id:
  id: abapCredentialsId
  reference to: username

verbose

verbose output

back to overview

Scope Details
Aliases -
Type bool
Mandatory no
Default false
Possible values - true
- false
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references none

abapCredentialsId

Jenkins-specific: Used for proper environment setup. See using credentials for details.

Jenkins credentials ID containing user and password to authenticate to the BTP ABAP Environment system or the Cloud Foundry API

back to overview

Scope Details
Aliases cfCredentialsId
Type string
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages

Examples

AUnit test run via direct ABAP endpoint configuration in Jenkinsfile

This example triggers an AUnit test run directly on the ABAP endpoint.

In order to trigger the AUnit test run you have to pass the username and password for authentication to the ABAP endpoint via parameters as well as the ABAP endpoint/host. You can store the credentials in Jenkins and use the abapCredentialsId parameter to authenticate to the ABAP endpoint/host.

This must be configured as following:

abapEnvironmentRunAUnitTest(
    abapCredentialsId: 'abapCredentialsId',
    host: 'https://myABAPendpoint.com',
    aUnitConfig: 'aUnitConfig.yml',
    script: this,
)

To trigger the AUnit test run an AUnit config file aUnitConfig.yml will be needed. Check the section 'AUnit config file example' for more information.

AUnit test run via Cloud Foundry Service Key example in Jenkinsfile

The following example triggers an AUnit test run via reading the Service Key of an ABAP instance in Cloud Foundry.

You can store the credentials in Jenkins and use the cfCredentialsId parameter to authenticate to Cloud Foundry. The username and password to authenticate to ABAP system will then be read from the Cloud Foundry Service Key that is bound to the ABAP instance.

This can be done accordingly:

abapEnvironmentRunAUnitTest(
    cfApiEndpoint: 'https://test.server.com',
    cfOrg: 'cfOrg',
    cfSpace: 'cfSpace',
    cfServiceInstance: 'myServiceInstance',
    cfServiceKeyName: 'myServiceKey',
    abapCredentialsId: 'cfCredentialsId',
    aUnitConfig: 'aUnitConfig.yml',
    script: this,
)

To trigger the AUnit test run an AUnit config file aUnitConfig.yml will be needed. Check the section 'AUnit config file example' for more information.

AUnit test run via direct ABAP endpoint configuration in Jenkinsfile

This example triggers an AUnit run directly on the ABAP endpoint.

In order to trigger the AUnit run you have to pass the username and password for authentication to the ABAP endpoint via parameters as well as the ABAP endpoint/host. You can store the credentials in Jenkins and use the abapCredentialsId parameter to authenticate to the ABAP endpoint/host.

This must be configured as following:

abapEnvironmentRunAUnitTest(
    abapCredentialsId: 'abapCredentialsId',
    host: 'https://myABAPendpoint.com',
    aUnitConfig: 'aUnitConfig.yml',
    script: this,
)

To trigger the AUnit run an AUnit config file aUnitConfig.yml will be needed. Check section 'AUnit config file example' for more information.

AUnit config file example

Providing a specifc AUnit configuration is optional. If you are using a repositories.yml file for the Clone stage of the ABAP environment pipeline, a default AUnit configuration will be derived if no explicit AUnit configuration is available.

The following section contains an example of an aUnitConfig.yml file. This file must be stored in the same Git folder where the Jenkinsfile is stored to run the pipeline. This repository containing the Jenkinsfile must be taken as a SCM in the Jenkins pipeline to run the pipeline.

You can specify a Multi Property Set containing multiple properties that should be checked. Each property that is specified in the Multi Property Set acts like an additional rule. This means if you specify e.g. a Multi Property Set containing the owner and package properties that an ABAP Unit test run will be started testing all objects belonging to this owner inside of the given package. If you additionally define the Version to be ACTIVE for the ABAP Unit test run inside of the Multi Property Set, only objects belonging to this owner which are active inside of the package would be tested. This must be in the same format as below examples for a aUnitConfig.yml file. Note that if you want to check complete software components we recommend to use the softwareComponent property over the package property.

See below example for an aUnitConfig.yml file containing a minimal configuration for the software component /DMO/SWC to be checked:

title: My AUnit run
context: My unit tests
objectset:
  softwarecomponents:
    - name: /DMO/SWC

See below example for an aUnitConfig.yml file with the configured options containing the package Z_TEST_PACKAGE to be checked:

title: My AUnit run
context: My unit tests
objectset:
  packages:
    - name: Z_TEST_PACKAGE

The following example of an aUnitConfig.yml file containing the software component Z_TESTSC and shows the available options:

title: My AUnit run
context: My unit tests
options:
  measurements: none
  scope:
    ownTests: true
    foreignTests: true
  riskLevel:
    harmless: true
    dangerous: true
    critical: true
  duration:
    short: true
    medium: true
    long: true
objectset:
  softwarecomponents:
    - name: Z_TESTSC

The following example of an aUnitConfig.yml file contains all possible properties of the Multi Property Set that can be used. Please take note that this is not the reccommended approach. If you want to check packages or software components please use the two above examples. The usage of the Multi Property Set is only reccommended for ABAP Unit tests that require these rules for the test execution. There is no official documentation on the usage of the Multi Property Set.

title: My AUnit run
context: My unit tests
options:
  measurements: none
  scope:
    ownTests: true
    foreignTests: true
  riskLevel:
    harmless: true
    dangerous: true
    critical: true
  duration:
    short: true
    medium: true
    long: true
objectset:
  type: multiPropertySet
  multipropertyset:
    owners:
      - name: demoOwner
    softwarecomponents:
      - name: demoSoftwareComponent
    versions:
      - value: ACTIVE
    packages:
      - name: demoPackage
    objectnamepatterns:
      - value: 'ZCL_*'
    languages:
      - value: EN
    sourcesystems:
      - name: H01
    objecttypes:
      - name: CLAS
    objecttypegroups:
      - name: CLAS
    releasestates:
      - value: RELEASED
    applicationcomponents:
      - name: demoApplicationComponent
    transportlayers:
      - name: H01