1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-14 11:03:09 +02:00
sap-jenkins-library/documentation/docs/steps/abapEnvironmentRunAUnitTest.md
Dominik Lendle 09f5c0a524
AUnit step (#3075)
* Add AUnit step

* Add Groovy File

* Update metadata

* Add groovy test config

* Add Unit tests

* Add Documentation

* Docu fixes

* change docu

* change docu

* change logging level & remove sleep

* change docu

* change docu

* Update documentation/docs/steps/abapEnvironmentRunAUnitTest.md

Co-authored-by: Daniel Mieg <56156797+DanielMieg@users.noreply.github.com>
2021-09-20 11:14:13 +02:00

6.4 KiB

${docGenStepName}

${docGenDescription}

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.

${docGenParameters}

${docGenConfiguration}

${docJenkinsPluginDependencies}

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

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 an object set containing the objects that should be checked. These can be for example packages, classes or transport requests containing test classes that can be executed. This must be in the same format as below example for a aUnitConfig.yml file. Note that if you specify a package inside a packageSet to be checked for each package that has to be checked you can configure if you want the subpackages to be included in checks or not.

See below example for an aUnitConfig.yml file containing a package to be checked:

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: unionSet
    set:
      - type: packageSet
        package:
          - name: my_package
            includesubpackages: false

The following example of an aUnitConfig.yml file containing one class and one interface to be checked:

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: unionSet
    set:
      - type: flatObjectSet
        object:
        - name: my_class
          type: CLAS
        - name: my_interface
          type: INTF