Now accepting guest editorial from SAP, Oracle, Workday and ServiceNow practitioners.Pitch a guide
The Sign-Off Table

Lesson 4 of 6

UI tests with QUnit and OPA5

8 min

Listen to this lesson

0:00 / 6:59

The fleet desk works in an SAP Fiori elements app, and some custom screens use freestyle SAPUI5. UI tests answer questions service tests cannot: does the filter bar offer the right fields, does the object page show notes, does the Close action appear for supervisors and not for agents, does navigation work? SAPUI5 delivers its own test tools for this, and SAP's documentation recommends them along the testing pyramid.

QUnit for unit tests

QUnit is the JavaScript unit test framework used with SAPUI5. Use it for small pieces of UI logic in isolation: formatters (turning a delivery status code into text and color), helper functions, and controller methods with their dependencies replaced. QUnit tests are fast and precise but say nothing about how screens behave together.

OPA5 for integration tests

OPA5 (One Page Acceptance tests) is part of SAPUI5 and built on QUnit. SAP's documentation describes it as an API for SAPUI5 controls that hides asynchronicity and eases access to UI elements, which makes it suited to testing user interactions, navigation and data binding. OPA5 tests follow the arrange, act, assert pattern, written as Given, When and Then, and are usually organized in page objects that bundle actions and assertions per screen. They wait for controls by polling instead of fixed time-outs, which makes them faster and less flaky.

  1. GivenStart the app with mock data and the fleet agent role
  2. WhenThe agent filters the list report by status New and opens the first inquiry
  3. ThenThe object page shows the inquiry with its notes table
  4. And thenThe Close action is not available to the agent
  5. TeardownThe app is torn down so the next journey starts clean
An OPA5 journey for the fleet desk, written in Given, When, Then form.
The Sign-Off Table · thesignofftable.com/academy/sap-btp-301

For apps generated with SAP Fiori elements for OData V4, SAP provides an OPA test library with reusable test functions for common steps such as starting the app, loading data, using the filter bar, opening objects and navigating. Teams then write only the app-specific checks. SAP's tutorial combines the library with static and dynamic mock data, so these tests run without a back end.

QUnitOPA5Browser end-to-end
TestsSingle functions and controller logicScreens, interactions, navigation, bindingWhole journeys in a real browser against a real landscape
DataInputs in the testMock server or local CAP with mock dataReal test data in CMQ and the app
SpeedMillisecondsSeconds per journeyMinutes per journey
LimitsNo screen behaviorSingle app page, no remote execution, not for end-to-end (per SAP)Slow, sensitive to data and authentication
Choosing the right UI test tool.
The Sign-Off Table · thesignofftable.com/academy/sap-btp-301

Know OPA5's limits

SAP's documentation lists OPA5's restrictions: no screen capturing, no testing across more than one page, no remote test execution, and it does not recommend OPA for end-to-end tests because of authentication issues and fragile test data. For journeys that cross the launchpad, sign-in and several apps, teams use WebDriver-based browser automation; open-source UI5-aware plugins add control locators and synchronization with the SAPUI5 framework. Choose such tools by criteria rather than popularity: SAPUI5 control awareness, waiting that follows the framework rather than fixed delays, support for your identity provider's sign-in, headless runs in the pipeline, readable reports and screenshots for evidence.

Pick the UI test tool by scope: QUnit for logic, OPA5 for screens in one app with mock data, and browser automation for journeys across sign-in and the launchpad.
The Sign-Off Table · thesignofftable.com/academy/sap-btp-301

What would you do?

A test engineer writes OPA5 tests that sign in to the real identity provider, open the launchpad in cmc-ext-test, start the fleet app and check data that Maria created in CMQ that morning. The tests fail randomly. What should the test lead recommend?

Key points
  • QUnit tests UI logic such as formatters in isolation.
  • OPA5 tests screens, interactions and navigation with Given, When, Then and page objects, against mock data.
  • The SAP Fiori elements OPA test library supplies reusable steps for V4 apps.
  • SAP does not recommend OPA5 for end-to-end tests; use browser automation chosen by clear criteria.
  • Locate controls by stable meaning, not generated IDs or positions.

Check your understanding · not graded

Lesson check

  1. 1. Which tool fits testing a formatter that turns a status code into text?

  2. 2. What pattern do OPA5 tests follow?

  3. 3. What does SAP say about OPA5 for end-to-end tests?

  4. 4. What does the SAP Fiori elements OPA test library provide?