Watch this short video to learn about OPA5, its advantages, and limitations.
After completing this lesson, you will be able to:
Watch this short video to learn about OPA5, its advantages, and limitations.
As we have already seen in the QUnit-lesson, the start of the OPA-tests is also implemented using a different html-file. The file is called the opaTests.qunit.html
file and contains the bootstrapping code for the execution of OPA-tests. The bootstrapping file is generated by the SAP Business Applicaton Studio during project generation.
Let us now look at bootstrapping, library loading, and test initiation.
Each test case scenario is implemented in a different JavaScript file.
The following two figures describe the anatomy of an OPA5 test case.
The above figure shows a test implementation. The test case is set to check whether or not the component with the namespace sap.training.optest.integration.button
can be loaded or not.
The function opaTest is the main aspect for defining integration tests with OPA. Its parameters define a test name and a callback function that gets executed with the following OPA5 helper objects to write meaningful tests that read like a user story.
The OPA5 framework provides us different possibilities to get a reference to a UI control on the view. One option is to get a reference by the id of the control. The following figure shows the key aspects involved in the retrieval of a control by ID.
Besides the retrieval of a UI control by id, it is also possible to use so called matchers. The following figure shows matchers retrieving a control without an ID but using a matcher. In this case, a sap.ui.test.matchers.PropertyStrictEquals
is used. We want to get all controls of type sap.m.Button
, where the property text
contains the value Press me
. You can find more matcher implementations in the namespace sap.ui.test.matchers
of the SAPUI5-API-documentation (https://ui5.sap.com/#/api/sap.ui.test.matchers).
Log in to track your progress & complete quizzes