github.com/ouraigua/jenkins-library@v0.0.0-20231028010029-fbeaf2f3aa9b/documentation/docs/steps/abapEnvironmentRunAUnitTest.md (about)

     1  # ${docGenStepName}
     2  
     3  ## ${docGenDescription}
     4  
     5  !!! 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`.
     6  
     7  ## Prerequisites
     8  
     9  * A SAP BTP, ABAP environment system is available. On this system, a [Communication User](https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/0377adea0401467f939827242c1f4014.html), a [Communication System](https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/1bfe32ae08074b7186e375ab425fb114.html) and a [Communication Arrangement](https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/a0771f6765f54e1c8193ad8582a32edb.html) 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](https://sap.github.io/jenkins-library/steps/cloudFoundryCreateServiceKey/).
    10  * 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.
    11  * 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.
    12  * 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.
    13  
    14  ## ${docGenParameters}
    15  
    16  ## ${docGenConfiguration}
    17  
    18  ## ${docJenkinsPluginDependencies}
    19  
    20  ## Examples
    21  
    22  ### AUnit test run via direct ABAP endpoint configuration in Jenkinsfile
    23  
    24  This  example triggers an AUnit test run directly on the ABAP endpoint.
    25  
    26  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.
    27  
    28  This must be configured as following:
    29  
    30  ```groovy
    31  abapEnvironmentRunAUnitTest(
    32      abapCredentialsId: 'abapCredentialsId',
    33      host: 'https://myABAPendpoint.com',
    34      aUnitConfig: 'aUnitConfig.yml',
    35      script: this,
    36  )
    37  ```
    38  
    39  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.
    40  
    41  ### AUnit test run via Cloud Foundry Service Key example in Jenkinsfile
    42  
    43  The following example triggers an AUnit test run via reading the Service Key of an ABAP instance in Cloud Foundry.
    44  
    45  You can store the credentials in Jenkins and use the cfCredentialsId parameter to authenticate to Cloud Foundry.
    46  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.
    47  
    48  This can be done accordingly:
    49  
    50  ```groovy
    51  abapEnvironmentRunAUnitTest(
    52      cfApiEndpoint: 'https://test.server.com',
    53      cfOrg: 'cfOrg',
    54      cfSpace: 'cfSpace',
    55      cfServiceInstance: 'myServiceInstance',
    56      cfServiceKeyName: 'myServiceKey',
    57      abapCredentialsId: 'cfCredentialsId',
    58      aUnitConfig: 'aUnitConfig.yml',
    59      script: this,
    60  )
    61  ```
    62  
    63  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.
    64  
    65  ### AUnit test run via direct ABAP endpoint configuration in Jenkinsfile
    66  
    67  This  example triggers an AUnit run directly on the ABAP endpoint.
    68  
    69  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.
    70  
    71  This must be configured as following:
    72  
    73  ```groovy
    74  abapEnvironmentRunAUnitTest(
    75      abapCredentialsId: 'abapCredentialsId',
    76      host: 'https://myABAPendpoint.com',
    77      aUnitConfig: 'aUnitConfig.yml',
    78      script: this,
    79  )
    80  ```
    81  
    82  To trigger the AUnit run an AUnit config file `aUnitConfig.yml` will be needed. Check section 'AUnit config file example' for more information.
    83  
    84  ### AUnit config file example
    85  
    86  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.
    87  
    88  The following section contains an example of an `aUnitConfig.yml` file.
    89  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.
    90  
    91  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.
    92  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.
    93  This must be in the same format as below examples for a `aUnitConfig.yml` file.
    94  Note that if you want to check complete software components we recommend to use the `softwareComponent` property over the `package` property.
    95  
    96  See below example for an `aUnitConfig.yml` file containing a minimal configuration for the software component `/DMO/SWC` to be checked:
    97  
    98  ```yaml
    99  title: My AUnit run
   100  context: My unit tests
   101  objectset:
   102    softwarecomponents:
   103      - name: /DMO/SWC
   104  ```
   105  
   106  See below example for an `aUnitConfig.yml` file with the configured options containing the package `Z_TEST_PACKAGE` to be checked:
   107  
   108  ```yaml
   109  title: My AUnit run
   110  context: My unit tests
   111  objectset:
   112    packages:
   113      - name: Z_TEST_PACKAGE
   114  ```
   115  
   116  The following example of an `aUnitConfig.yml` file containing the software component `Z_TESTSC` and shows the available options:
   117  
   118  ```yaml
   119  title: My AUnit run
   120  context: My unit tests
   121  options:
   122    measurements: none
   123    scope:
   124      ownTests: true
   125      foreignTests: true
   126    riskLevel:
   127      harmless: true
   128      dangerous: true
   129      critical: true
   130    duration:
   131      short: true
   132      medium: true
   133      long: true
   134  objectset:
   135    softwarecomponents:
   136      - name: Z_TESTSC
   137  ```
   138  
   139  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.
   140  
   141  ```yaml
   142  title: My AUnit run
   143  context: My unit tests
   144  options:
   145    measurements: none
   146    scope:
   147      ownTests: true
   148      foreignTests: true
   149    riskLevel:
   150      harmless: true
   151      dangerous: true
   152      critical: true
   153    duration:
   154      short: true
   155      medium: true
   156      long: true
   157  objectset:
   158    type: multiPropertySet
   159    multipropertyset:
   160      owners:
   161        - name: demoOwner
   162      softwarecomponents:
   163        - name: demoSoftwareComponent
   164      versions:
   165        - value: ACTIVE
   166      packages:
   167        - name: demoPackage
   168      objectnamepatterns:
   169        - value: 'ZCL_*'
   170      languages:
   171        - value: EN
   172      sourcesystems:
   173        - name: H01
   174      objecttypes:
   175        - name: CLAS
   176      objecttypegroups:
   177        - name: CLAS
   178      releasestates:
   179        - value: RELEASED
   180      applicationcomponents:
   181        - name: demoApplicationComponent
   182      transportlayers:
   183        - name: H01
   184  ```