Fiori Testing Part 1: QUnit Unit Tests and OPA5 Integration Journeys
Free sample lesson · open to everyone
Test UI5 apps at the right levels: QUnit for formatters and logic, OPA5 journeys that drive the UI with page objects against mock data, and running them in the pipeline on every change.
In this lessonShow sectionsHide sections
Visual overview
The situation: a real project scenario
A small change to a status formatter broke colour coding across an app, discovered only by users. Adding QUnit tests for all formatters and an OPA5 journey covering the approval flow caught the next similar regression in the pipeline before deployment.
Explanation
This series covers automated testing, and Part 1 covers UI5's built-in test frameworks: QUnit and OPA5.
Formatters, validators and helper functions should be tested with QUnit: given an input, expect a given output. Keeping controllers thin, with most logic living in testable modules, is what makes this practical. Unit tests run in milliseconds and catch regressions early, before they reach the UI at all.
OPA5 (One Page Acceptance) tests simulate actual users: open the app, press a button, enter a value, check a result. Page objects encapsulate how to find controls and perform actions on a given page, so journeys read like user stories and stay maintainable as the app evolves.
Integration tests run against mock servers with fixed data, which makes results deterministic and independent of back-end availability. The same mock data used for development can simply be extended with additional test cases rather than maintained separately. Tests that depend on live back-end data instead become flaky over time and eventually get ignored.
For Fiori elements apps specifically, SAP provides test libraries with page objects for list reports and object pages, so tests can use high-level actions like "search" or "press Edit" without needing to know the generated control IDs underneath.
In the pipeline, unit and OPA tests should run headless in CI on every change, with coverage reports attached, and failing tests should block deployment. A small, reliable suite that always runs beats a large flaky one that gets ignored.
In practice, this means writing QUnit tests for two formatters, writing an OPA5 journey with page objects for a key flow, running the tests against mock data locally, and adding the tests to the CI pipeline — ending with unit and journey tests running automatically on every change and blocking failing builds.
How the SAP process fits together
SAP PROCESS EXPLORER · Fiori: from service to user
ERPClimb.comAutomated Testing for Fiori Apps — process breakdown
Topic-specific conceptual flow: how key objects and decisions fit together. SAP configurations and exceptional cases can follow different paths.
Selected process stage
Unit
QUnit tests check formatters and controller logic
Representative SAP learning flow, not a guarantee of system runtime sequence in every scenario.
Watch out
Common mistakes
Leaving formatters and utility functions untested because they "look too simple to break." A status-colour formatter with a one-character typo in a comparison can silently miscolour every record in an app, and because it's pure logic with no UI interaction, it's exactly the kind of bug a two-line QUnit test would catch instantly — yet it's also exactly the kind of code teams skip testing because it feels trivial.
Writing integration or OPA5 tests against live back-end data instead of deterministic mock data. A test that checks "there are 12 open orders for company code 1000" breaks the moment real data changes — not because the app broke, but because the data did — and teams eventually learn to distrust and ignore these tests, defeating their purpose.
Putting business and formatting logic directly in controllers where it's entangled with UI lifecycle code, instead of extracting it into separate, pure modules. Logic buried in a controller method that also handles event binding and navigation is much harder to unit test in isolation, so it often ends up untested entirely, by default rather than by choice.
Writing tests but never wiring them into the CI pipeline, so they only run when a developer remembers to run them locally. A test suite that isn't enforced on every change catches regressions only by luck — the actual value of automated testing comes from failing builds automatically, not from tests existing somewhere in the repo.
Do this
Best practices
Keep controllers thin and move formatters, validators and business logic into separate, pure modules — this is what makes QUnit testing practical, since logic entangled with controller lifecycle code is much harder to isolate and test.
Use page objects in OPA5 journeys to encapsulate how each page's controls are found and interacted with, so tests read like user stories and stay maintainable when the UI's internal structure changes — for Fiori elements apps, use SAP's provided test libraries with high-level actions (search, press Edit) instead of hand-rolling control lookups.
Run integration and OPA5 tests against deterministic mock data, not live back-end data — this is what keeps results reproducible and prevents tests from failing due to data changes that have nothing to do with the app itself.
Wire unit and OPA tests into the CI pipeline so they run headless on every change and failing tests block deployment — a small, reliable suite that always runs delivers more real protection than a large suite that's flaky and gets ignored.
In the interview
Interview angle
A typical interview question: "What's the difference between QUnit and OPA5 testing in UI5, and when do you use each?" A weak answer says "QUnit is for unit tests and OPA5 is for UI tests" without explaining why that split matters.
A strong answer explains that QUnit tests pure logic — formatters, validators, helper functions — in isolation and in milliseconds, which is why controllers should be kept thin so most logic lives in testable modules rather than tangled in controller code; OPA5, by contrast, drives the actual rendered UI through page objects (open the app, press a button, check a result) to verify real user journeys, which is slower but catches integration issues QUnit can't see.
The strong answer adds that OPA5/integration tests should run against deterministic mock data, not live back-end data, because tests tied to live data break when the data changes rather than when the app breaks — and that both layers need to run automatically in CI, failing the build, to actually prevent regressions from reaching production.
Practice this lesson
Original educational case studies for SAP consultants, not official SAP certification exam questions. Verify product edition and implementation details against the current SAP documentation.
Quick check
0 of 3 questions attempted
Question 1 of 3
What is QUnit typically used for in UI5 projects?
Question 2 of 3
What do OPA5 page objects do?
Question 3 of 3
Why run integration tests against mock data?
Practise this in an interview
Answer in your own words and get instant feedback, the way an interviewer would judge it.
1How do you set up automated testing for a UI5 app?
Was this lesson helpful?
Keep exploring
Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.