Code Monkey home page Code Monkey logo

vaibhavmojidra / sap-ui5---demo-integration-test-with-opa Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 907 KB

OPA (One Page Acceptance) is a testing framework provided by SAPUI5 for integration testing. OPA tests simulate user interactions with the application and check if the application behaves as expected.

Home Page: https://vaibhavmojidra.github.io/site/

License: MIT License

JavaScript 63.96% HTML 36.04%
integration-test mojidra opa sap sap-ui5 ui5 vaibhav vaibhav-mojidra vaibhavmojidra

sap-ui5---demo-integration-test-with-opa's Introduction

SAP UI5 Demo Integration Test With OPA

OPA (One Page Acceptance) is a testing framework provided by SAPUI5 for integration testing. OPA tests simulate user interactions with the application and check if the application behaves as expected.

Note

This demo created using VS Code.

Folder Structure

πŸ“‚ webapp
  πŸ“‚ controller
  πŸ“‚ i18n
  πŸ“‚ test
    πŸ“‚ integration
      πŸ“‚ pages
        πŸ“„ App.js
      πŸ“„ NavigationJourney.js
      πŸ“„ opaTests.qunit.html
      πŸ“„ opaTests.qunit.js
  πŸ“‚ view
  πŸ“„ index.html
  πŸ“„ Component.js
  πŸ“„ manifest.json
  πŸ“„ package.json

Code Explaination

Refer to /webapp/test/integration/NavigationJourney.js

The opaTest function is defined with three parameters: Given, When, and Then. The Given parameter is used to define the initial state of the application, the When parameter is used to define the user action, and the Then parameter is used to define the expected outcome.

In this code snippet, the opaTest function is used to test the navigation of the application. The test checks whether the β€œHello” dialog box is opened when the β€œSay Hello with Dialog” button is pressed. The Given parameter sets up the initial state of the application by starting the UI component with the name com.vaibhavmojidra.integrationtestwithopademo. The When parameter simulates the user action of pressing the β€œSay Hello with Dialog” button. The Then parameter checks whether the β€œHello” dialog box is displayed. Finally, the iTeardownMyApp function is called to clean up the application after the test is complete.

Refer to /webapp/test/integration/pages/App.js

The module has two dependencies: sap/ui/test/Opa5 and sap/ui/test/actions/Press. The Opa5.createPageObjects method is used to create a page object for the onTheAppPage object. The iPressTheSayHelloWithDialogButton function is defined to simulate the user action of pressing the β€œSay Hello with Dialog” button. The iShouldSeeTheHelloDialog function is defined to check whether the β€œHello” dialog box is displayed.

In this code snippet, the waitFor function is used to wait for the β€œSay Hello with Dialog” button to appear on the screen. Once the button appears, the Press action is used to simulate the user pressing the button. The waitFor function is then used again to wait for the β€œHello” dialog box to appear on the screen. If the dialog box appears, the test passes. If the dialog box does not appear, the test fails.

Refer to /webapp/test/integration/opaTests.qunit.html

This file contains our test suite for all OPA tests of the app. We use the same namespace as for our application.

Then we load the basic QUnit functionality via script tags from SAPUI5 so that we can execute the test journey. The NavigationJourney we defined above will be loaded via a script called opaTests.qunit.js below:

Refer to /webapp/test/integration/opaTests.qunit.js


Vaibhav Mojidra - 1.gif

sap-ui5---demo-integration-test-with-opa's People

Contributors

vaibhavmojidra avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.