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

Add Automated System Tests with the SAPUI5 Test Recorder to Your CI/CD Pipeline

Use the SAPUI5 Test Recorder to create system tests with UIVeri5 against the user interface of an SAPUI5/SAP Fiori application. Add the tests to a continuous integration and delivery pipeline to run them automatically.

Overview

🎓 beginner 60 min. SAP Business Technology PlatformBeginnerCloudSapui5SAP Fiori

You will learn

  • How to create system tests with UIVeri5 using the UI5 Test Recorder
  • How to create a CI/CD pipeline with project “Piper”
  • How to add system tests as automated steps to your CI/CD pipeline
Sarah Lendle S Sarah Lendle November 1, 2022
Created by April 21, 2020
Contributors

Prerequisites

Prerequisites

  • You use SAPUI5 in version 1.74 or higher.
  • You have installed Node JS in version 8.0 or higher.
  • You have installed Visual Studio Code.
  • You have installed UIVeri5 using the following command:
    Code
    npm install @ui5/uiveri5 -g
  • You have installed Yeoman and generator-easy-ui5 using the following command:
    Code
    npm install -g yo generator-easy-ui5
  • Your Google Chrome version is up to date. See Update Google Chrome.
  • You have a Jenkins instance that is preconfigured for using project “Piper”. See Configuration.
  • You have an account and a repository in GitHub.

Steps

Note

Please note that UIVeri5 is deprecated and will be removed or replaced soon. Even though existing tests will continue to work, we recommend that you remove the deprecated configurations. For more details, see GitHub.

What Is This Tutorial About?

In this tutorial, you’ll create and run automated system tests with UIVeri5 against a simple shopping app for electronic devices. Your test application has basic functions such as a product catalog sorted by categories, a search option, and an add to cart function.

Intro

The tutorial consists of three main stages:

Main Stages of Tutorial
Main Stages of Tutorial

  1. Set up your project and manually go through your test scenario before starting to code it.

  2. Create and run system tests with UIVeri5 to check the home screen of your application, its product search, and the navigation to a product.

  3. Automate your system tests by integrating them into a CI/CD pipeline.

About System Tests with UIVeri5

UIVeri5 is an SAP open-source JavaScript testing framework for SAPUI5 applications. It drives a real browser for your deployed app and simulates authentic user scenarios. System tests check both front-end and back-end and make sure that all pieces of an application work well together.

The following graphic shows the positioning of system tests with UIVeri5 compared to other testing methods and tools. The arrow shape illustrates the granularity of the methods: Compared to unit, component, or integration tests, system tests examine less details and focus on crucial workflows, instead.

Test Comparison
Test Comparison

For more information about testing with UIVeri5, have a look at these blogs:

About the SAPUI5 Test Recorder

The SAPUI5 Test Recorder is a tool that helps you create integration and system tests. You can use it in any SAPUI5 application to inspect its user interface, view the control properties, and get code snippets for OPA5 and UIVeri5 tests. As of version 1.74, it is part of the SAPUI5 framework.

For more information about the SAPUI5 Test Recorder, see Test Recorder.

About the Yeoman Generator for UIVeri5

Yeoman is a popular open-source command-line tool to create a scaffolding for either a complete project or parts of it. As of version 2.3.0., the UIVeri5 Yeoman generator is a sub-generator of the project generator-easy-ui5. It helps you kickstart your test suite and quickly write new tests with your own action and assertion logic for scenarios that are relevant for your use case.

For more information, see Yeoman generators for OPA5 and UIVeri5.

About CI/CD with Project “Piper”

Project “Piper” is one of SAP’s solutions for continuous integration and delivery. It provides pre-configured Jenkins pipelines, which you can use in your own Jenkins master infrastructure and adapt according your needs. Project “Piper” consists of two different parts:

  • A shared library, which contains the description of steps, scenarios, and utilities that are required to use Jenkins pipelines
  • A set of Docker images that can be used to implement best practice processes

For more information about SAP solutions for CI/CD, see:


Step 1 Set up your test project

In Visual Studio Code, set up your UIVeri5 test project.

  1. In Visual Studio Code, open a new terminal.

  2. Navigate to the folder to which you want to add your UIVeri5 project.

  3. Use the following command to call the generator for UIVeri5 tests:

    Shell/Bash
    yo easy-ui5 project uiveri5

    Now, you’re asked a couple of questions that help the generator create your test structure.

  4. Answer the questions as follows:

    QuestionAnswer
    Please enter the name of your projectuiveri5
    URL to the app under testhttps://sapui5.hana.ondemand.com/test-resources/sap/m/demokit/cart/webapp/index.html
    Choose authenticationnone
    Choose additional reportersJUNIT
    Do you want to add a page objectY
    Do you want to add a specY
    Page object nameHome
    Add action with namePress Enter to skip
    Add assertion with namePress Enter to skip
    Name for the suite (describe block)teched
    Name for the spec (it block)Should validate the home screen
  5. Press Enter. Now, your project structure is generated.

    Questions for generating the project structure
    Questions for generating the project structure

  6. In Visual Studio Code, open the folder uiveri5. As a result, the project uiveri5 is loaded into the EXPLORER pane and you can see its resources in the outline:

    Resources in the EXPLORER pane
    Resources in the EXPLORER pane

    Like all system tests with UIVeri5, you’ll define your tests through different files:

    • (a) The conf.js file:

      In this file, you can define, for example, the browser and reporter that are used, the base URL, and the credentials for your login dialog.

    • (b) The spec.js file (in this case, it’s called teched.spec.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.

    • (c) Page objects (in this case, you have home.js for the home screen and product.js for the detail view of a product):

      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, entering a specific text in a search field and triggering the search
      - Assertions, for example, getting a search result that matches the previously entered text
      

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

      If you want to set up a project for an application that is protected by credentials, you need to add authentication configurations. See Authentication.

  7. To check if the test execution works, choose Terminal New Terminal in the root folder of your project, and enter the following command:

    Shell/Bash
    uiVeri5

    As a result, the browser briefly opens to execute the tests. However, as you haven’t defined any tests, yet, the application doesn’t load.

  8. In the terminal response, check if the test execution has been successful:

    Terminal Response: Successful
    Terminal Response: Successful

Step 2 Walk through the test scenario
+
Step 3 Test the home screen
+
Step 4 Test the product search
+
Step 5 Test the navigation to a product
+
Step 6 Integrate your system tests into a CI/CD pipeline
+

Resources

Discussion

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

Submit detailed feedback Discuss in Community
Steps
Step 1 of 6
1. Set up your test project 2. Walk through the test scenario 3. Test the home screen 4. Test the product search 5. Test the navigation to a product 6. Integrate your system tests into a CI/CD pipeline

Learn more →