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

Write OPA Tests for an SAP Fiori Elements for OData V4 Application

Reuse test functions from the SAP Fiori elements for OData V4 OPA test library to write OPA (One Page Acceptance) tests.

Overview

🎓 beginner 30 min. SAP FioriBeginnerSAP Fiori Tools

You will learn

  • βœ”How to use the generated OPA test files within the embedded test structure
  • βœ”How to start the tests within the development environment
  • βœ”How to implement OPA tests using the SAP Fiori elements for OData V4 OPA test library
Created by January 14, 2022
Contributors

Prerequisites

Prerequisites

Steps

Step 1 Introduction
β€”

  1. Why should you use the SAP Fiori elements for OData V4 OPA test library to write OPA tests?

    The OPA test library provides a set of test functions that can be reused within OPA tests of SAP Fiori elements for OData V4 applications. When you write such OPA tests, you only need to test the application-specific functionalities. The core functionalities provided by SAP Fiori elements are already tested by the framework itself.

    Nevertheless, you need to implement certain steps to test the specific functionalities of the app, e.g. starting the app, loading data into the list-report, navigating between a list-report and an object-page, saving business objects, etc. To implement these steps within an OPA test, you can reuse the test functions of the OData V4 OPA test library and you donΒ΄t need to re-implement these functions. This saves time and avoids redundancy.

    Another advantage of using the OData V4 OPA test library is that updates for the test functions due to framework changes are automatically provided by the framework. This ensures that your tests will not break.

  2. Generated OPA test folders and files

    When an SAP Fiori elements app is generated using SAP Fiori tools, the files you need for executing OPA tests are already provided. You can find these files in the /test folder of the generated application.

    These test structures are created when you generate your application based on a RAP service.

  3. OData service and application used for this tutorial

    URL
    https://github.com/SAP-samples/fiori-elements-incident-management/tree/sampleSolution

    In this branch of the repository the /test folder is already available and you can directly start the tests. If you run through the CAP-based tutorial manually, the /test folder will not be created when the application is generated. However, you can copy the folder from the /sampleSolution branch into the application to execute the tests.

    • You can, of course, also use any other service/application to apply the steps shown within this tutorial. When you implement the test functions, you have to align the parameter values of the functions accordingly.
  4. Data used for executing the application

    You can run your tests using either static or dynamic mock data.

    • Static mock data

      This is the preferred option for executing OPA tests. You can store the mock data as json files in the /localService/mockdata folder and each time the server and the application are restarted, the same set of data is loaded. This means the tests are always based on the same set of data.

      For this tutorial, a very simple set of static mock data is used, which consists of two json files: Travel.json and Booking.json. The data that is contained in these files is sufficient to run the test functions used in the tutorial. You can downloaded these files from the GitHub repository with the URL below:

      URL
      https://github.com/SAP-samples/fiori-elements-incident-management/tree/sampleSolution/app/incidents/webapp/localService/mockdata_RAP_service

      You can find the two files in the /mockdata_RAP_service folder of this branch. You can copy these files to the /localService/mockdata folder of the application. Note that these mock data files can only be used for the application that was created by going through the steps of the tutorial Create a Travel App with SAP Fiori Elements Based on OData V4 RAP Service.

    • Dynamic mock data

      The mock server generates mock data dynamically when you start the application. Note that, when you use dynamic mock data, you cannot rely on the same set of test data always being used.

Β 

Step 2 Test resources within an SAP Fiori elements application
+
Step 3 Journey test files generated by SAP Fiori tools
+
Step 4 Start the tests
+
Step 5 Documentation for the SAP Fiori elements for OData V4 OPA test library
+
Step 6 Enhancing the OPA journey - testing the list-report
+
Step 7 Testing the object-page
+

Resources

Discussion

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

Submit detailed feedback Discuss in Community
Steps
Step 1 of 7
1. Introduction 2. Test resources within an SAP Fiori elements application 3. Journey test files generated by SAP Fiori tools 4. Start the tests 5. Documentation for the SAP Fiori elements for OData V4 OPA test library 6. Enhancing the OPA journey - testing the list-report 7. Testing the object-page

Learn more →