Lesson 4 of 6
UI tests with QUnit and OPA5
8 min
Listen to this lesson
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.
- GivenStart the app with mock data and the fleet agent role
- WhenThe agent filters the list report by status New and opens the first inquiry
- ThenThe object page shows the inquiry with its notes table
- And thenThe Close action is not available to the agent
- TeardownThe app is torn down so the next journey starts clean
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.
| QUnit | OPA5 | Browser end-to-end | |
|---|---|---|---|
| Tests | Single functions and controller logic | Screens, interactions, navigation, binding | Whole journeys in a real browser against a real landscape |
| Data | Inputs in the test | Mock server or local CAP with mock data | Real test data in CMQ and the app |
| Speed | Milliseconds | Seconds per journey | Minutes per journey |
| Limits | No screen behavior | Single app page, no remote execution, not for end-to-end (per SAP) | Slow, sensitive to data and authentication |
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.
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?
- 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. Which tool fits testing a formatter that turns a status code into text?
2. What pattern do OPA5 tests follow?
3. What does SAP say about OPA5 for end-to-end tests?
4. What does the SAP Fiori elements OPA test library provide?