SAP Home Learn Build Integrate Model Operate Extend with AI ConnectTutorial navigator Knowledge Graph API Devtoberfest Developer Advocates App Space

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
β€’ Open full site

Create Automated System Tests for SAP Cloud Application Programming Model Projects

Create wdi5 tests against an SAP Cloud Application Programming Model application and add them to your SAP Continuous Integration and Delivery job.

Overview

🎓 beginner 60 min. SAP Cloud Application Programming ModelBeginnerCloudUser InterfaceSAP Business Technology Platform

You will learn

  • βœ”How to create system tests with wdi5 for SAP Cloud Application Programming Model projects using the Test Recorder
  • βœ”How to add system tests as automated steps to your SAP Continuous Integration and Delivery job
Sarah Lendle S Sarah Lendle October 20, 2023
Created by July 22, 2023
Contributors

Prerequisites

Prerequisites

Steps

Step 1 Set up and run your sample application
β€”

In Visual Studio Code, set up and run your bookshop application.

  1. Before you start working, fork this repository to your personal GitHub account. See Forking a repository.

  2. In Visual Studio Code, choose View β†’ Command Palette… β†’ Git:Clone.

  3. As Repository URL, enter:

    URL
    https://github.com/<your github username>/cap-bookshop-wdi5.git
  4. Choose Select Repository Location and select a folder into which to clone the test repository.

  5. When asked if you want to open the cloned repository, choose Open.

    As a result, the CAP-BOOKSHOP-WDI5 project is loaded into the EXPLORER pane and you can see its resources in the outline:

    Resources of the project in the explorer pane
    Resources of the project in the explorer pane

  6. In Visual Studio Code, choose Terminal β†’ New Terminal.

  7. Execute the following command to install the npm packages:

    Shell/Bash
    npm install
  8. Execute the following command to start your bookshop application:

    Shell/Bash
    npm run start
  9. To open a new terminal, choose Terminal β†’ New Terminal.

  10. Execute the following command to call the quick start installation of wdi5:

    Shell/Bash
    npm init wdi5@latest -- --configPath ./app/admin-books/webapp/test/wdi5/ --specs ./**/wdi5/specs/**.js --baseUrl http://localhost:4004/fiori-apps.html\#Books-manage

    The console output should look as follows:

    Terminal response for the ’npm init wdi5’ command
    Terminal response for the ’npm init wdi5’ command

  11. In your project in the EXPLORER pane, choose app β†’ admin-books β†’ webapp β†’ test β†’ wdi5.

    Now you can see all files you need to define system tests with wdi5:

    • The wdio.conf.js file:

      In this file, you’ll define the settings for the wdi5 plugin, for example the browser and reporter, as well as the URL to access the SAP Fiori app under test.

    • The test.js file (in this case, it’s called bookshop.test.js):

      In this file, you’ll define your test scenario, which comprises steps that are triggered one after the other. Within the test scenario, you’ll refer to your page objects.

    • Page objects (in this case, you have pageobjects/manageBooks.page.js for the list of books that are added and the button to create a new book, and pageobjects/newBook.page.js to provide the details of the new book):

      Page objects are design patterns that represent a significant part of an app, for example, a view. They group two kinds of elements:

       - Actions, for example, choosing the **Create** button to create a new book
       - Assertions, for example, checking if the newly created book is displayed in the list of books
      

      Page objects reside in the pageobjects folder of your project. They use locators to identify specific elements on the screen and thereby, allow test runners to see and do anything a real user would.

  12. Execute the following command to install the timeline reporter:

    Shell/Bash
    npm run install --save-dev wdio-timeline-reporter

    The console output should look as follows:

    Terminal response for the ’npm install –save wdio-timeline-reporter’ command
    Terminal response for the ’npm install –save wdio-timeline-reporter’ command

  13. In the wdio.conf.js file, add the following snippets to configure the timeline reporter and the Chrome browser:

    JavaScript
    const { TimelineService } = require("wdio-timeline-reporter/timeline-service");
    exports.config = {
    // ...
    
    JavaScript
    // ...
    services: ['chromedriver','ui5', [TimelineService]],
    // ...
    
    JavaScript
    // ...
    reporters: ['spec',[
        "timeline",
        {
            outputDir: "target",
            embedImages: true,
            screenshotStrategy: "before:click",
        },
        ]
    ],
    // ...
    
    JavaScript
    // ...
    capabilities: [{
        maxInstances: 5,
        browserName: 'chrome',
        acceptInsecureCerts: true,
        "goog:chromeOptions": {
            args: ["--no-sandbox", "--disable-dev-shm-usage"]
        }
    }],
    // ...
    
  14. Now, your project setup is ready. Make sure that your code looks as follows and choose File β†’ Save.

    wdio.conf.js after finishing the project setup without comments
    wdio.conf.js after finishing the project setup without comments

Step 2 Walk through the test scenario
+
Step 3 Create a test for adding a new book
+
Step 4 Create a test for adding detailed information to your book
+
Step 5 Configure your SAP BTP credentials in SAP Continuous Integration and Delivery
+
Step 6 (Optional) Configure your GitHub credentials in SAP Continuous Integration and Delivery
+
Step 7 Add your repository to SAP Continuous Integration and Delivery
+
Step 8 Integrate your system tests into your SAP Continuous Integration and Delivery job
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 8
1. Set up and run your sample application 2. Walk through the test scenario 3. Create a test for adding a new book 4. Create a test for adding detailed information to your book 5. Configure your SAP BTP credentials in SAP Continuous Integration and Delivery 6. (Optional) Configure your GitHub credentials in SAP Continuous Integration and Delivery 7. Add your repository to SAP Continuous Integration and Delivery 8. Integrate your system tests into your SAP Continuous Integration and Delivery job

Learn more →