๐ฅ๏ธ How to demo¶
โ The repository
training-ui5con18-opacontains a sample UI5 application with qUnit and OPA tests. The project was modified to support many execution modes, including online, local with@ui5/clior with a standalone web server (reserve).
- Clone the project
training-ui5con18-opa - Change the current working directory to the cloned project and run
npm install - Install
ui5-test-runnerglobally withnpm install ui5-test-runner --global
Testing with Karma¶
โ
Karmarequires configuration files, the execution model is based on sequential execution of all tests in one window. Last but not least, it is deprecated.
- Run
npm run karmato test with the karma runner - Browser is visible
-
No coverage
-
Run
npm run karma-cito test with the karma runner - Browser is hidden
-
Coverage is extracted
-
Open
webapp\test\testsuite.qunit.htmlwhich defines the test pages
ui5-test-runner¶
- Run
ui5-test-runner --help, the list of available options is displayed - Open
https://arnaudbuchholz.github.io/ui5-test-runner/to access complete documentation
โ Some options are associated with an icon indicating in which mode it is supported :
- ๐ป for legacy mode
- ๐ for remote mode
- ๐งช for capabilities mode
These modes are detailed below.
๐ป Legacy mode¶
โ The initial version of
ui5-test-runnerwas designed to serve the application and run tes tests.
Serving the application¶
Default UI5 mapping¶
- Run
ui5-test-runner --port 8081 --serve-only - Browse to
http://localhost:8081/, the application starts - In the application, use
[CTRL] + [SHIFT] + [P]to see UI5 version
Changing UI5 version¶
- Browse to
https://ui5.sap.com/neo-app.json, it enumerates the list of available versions - Pick a version and run
ui5-test-runner --port 8081 --serve-only --ui5 https://ui5.sap.com/<version> - For instance :
ui5-test-runner --port 8081 --serve-only --ui5 https://ui5.sap.com/1.118.1 - In a new browser window, open the debugger
- Disable the browser cache
- Browse to
http://localhost:8081/, the application starts - In the application, use
[CTRL] + [SHIFT] + [P]to see UI5 version
โ The switch works because the application does not use a fixed version of UI5. Instead, it loads a relative URL (
./resources/sap-ui-core.js).
- In the debugger, go to the elements tab and expand the
<head>tag
โ ๏ธ By default,
http://localhost:8081/resources/sap-ui-core.jsredirects tohttps://ui5.sap.com/resources/sap-ui-core.js. Depending on the network settings, this may slow down the tests. The--cacheoption enables the caching of UI5 files locally to speed up the tests.
Running the qUnit and OPA tests¶
- Run
ui5-test-runner --port 8081 --serve-only - Browse to
http://localhost:8081/test/testsuite.qunit.html
Testing the application¶
- Run
ui5-test-runner --port 8081 - Follow the progress of the tests using
http://localhost:8081/_/progress.html - Open
report/output.txt, it summarizes the tests execution - Open
report/report.htmlin the browser, it details the tests execution
โ The runner logs everything (depending on the instantiation command). Each test page is associated to a folder which name is shown in front of the page URL in the
output.txt. For instance,http://localhost:8081/test/unit/unitTests.qunit.htmlis associated to the folderle6KDh_XnDk. The folder name is a hash based on the test page URL.
- Expand the folder associated to the unit tests (
le6KDh_XnDk) done.png: a screenshot captured after tests completionconsole.csv: the browser console logsnetwork.csv: the browser network tracesbrowser.json: (internal) the browser instantiation filestdout.txt: (internal) the driver standard outputstderr.txt: (internal) the driver error output- Expand the folder associated to the
TodoListJourneyjourney (9NHJd7F6A5c) <testid>-<elapsed>.png: screenshots are captured for every assertion
"Faster" testing¶
โ Performance is impacted by a variety of factors, augmenting the number of workers does not guarantee faster execution.
- Run
ui5-test-runner --port 8081 --parallel 4 - Follow the progress of the tests using
http://localhost:8081/_/progress.html
Custom reporting¶
- Run
ui5-test-runner --port 8081 --report-generator $/report.js $/junit-xml-report.js - Follow the progress of the tests using
http://localhost:8081/_/progress.html - Open
report/junit.xml
Code coverage¶
- Run
ui5-test-runner --port 8081 --coverage - At the end of the execution, a textual report summarizes the coverage
- Open
coverage/lcov-report/index.htmlin the browser - Open
coverage/lcov.infofor raw coverage information
โ Thresholds can be defined to fail the command line if the coverage is below the expected ratio, see
--coverage-check-branches,--coverage-check-functions,--coverage-check-lines,--coverage-check-statement.โ Coverage instrumentation is based on
nyc, the process can be customized with a configuration file and the option--coverage-settings.
- Run
ui5-test-runner --port 8081 --coverage --keep-alive - Browse to
http://localhost:8081/component.jsto see instrumentated version
๐ Remote mode¶
โ Starting with version 2,
ui5-test-runnercan execute UI5 tests even when the application is served externally.
UI5 sample applications¶
- Browse to https://ui5.sap.com/#/demoapps
- Open the Browse Orders application
- The demo page also document tests links :
- Run Unit Tests
- Run Integration Tests
- Run
ui5-test-runner --url https://ui5.sap.com/test-resources/sap/m/demokit/orderbrowser/webapp/test/unit/unitTests.qunit.html --url https://ui5.sap.com/test-resources/sap/m/demokit/orderbrowser/webapp/test/integration/opaTests.qunit.html - Follow the progress of the tests using
http://localhost:8081/_/progress.html
UI5 tooling¶
โ The UI5 tooling is the recommended way to develop UI5 applications.
- Run
npm start - Browse to
http://localhost:8080 - Navigate to
test/ - Run
ui5-test-runner --port 8081 --url http://localhost:8080/test/testsuite.qunit.html - Follow the progress of the tests using
http://localhost:8081/_/progress.html
Coverage with @ui5/middleware-code-coverage¶
- Run
npm start - Open
ui5.yaml - The
@ui5/middleware-code-coveragecan instrument files on the fly - Open
http://localhost:8080/component.jsin a new browser window - Open
http://localhost:8080/component.js?instrumented=truein a new browser window - Run
ui5-test-runner --port 8081 --url http://localhost:8080/test/testsuite.qunit.html --coverage - Follow the progress of the tests using
http://localhost:8081/_/progress.html
Any server¶
- Run
npm run reserve - Browse to
http://localhost:8080, the application starts - Run
ui5-test-runner --port 8081 --url http://localhost:8080/test/testsuite.qunit.html - Follow the progress of the tests using
http://localhost:8081/_/progress.html
Coverage proxy¶
โ This feature is experimental.
- Run
npm run reserve - Run
ui5-test-runner --port 8081 --url http://localhost:8080/test/testsuite.qunit.html --coverage --coverage-proxy --coverage-proxy-exclude test --disable-ui5
๐งช Capabilities tester¶
- Run
ui5-test-runner --capabilities - Run
ui5-test-runner --capabilities --browser $/selenium-webdriver.js