Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

readme.md

Chapter 08 - Testing: Automating Tests

By the end of this chapter, we will know how to automate our test setup.

Steps

1. Configure ui5-test-runner (test automation)

In the past, Karma was used for the automated execution of QUnit and/or OPA tests. As Karma has been deprecated, two alternatives emerged:

  1. ui5-test-runner
  2. wdio-qunit-service

Both can be seen as drop-in replacement to Karma, but wdio-qunit-service makes most sense, if WDI5 is already in use. The openui5-sample-app is using the ui5-test-runner, which is why we also use it here. Luckily, there is not much configuration to do - we only have to install the package and add a script to our package.json file.

➡️ Run the following command from the codejam.supermarket/uimodule/ directory:

# make sure you are in the uimodule/ directory
npm install ui5-test-runner -D

➡️ Add the following code to the scripts section of the codejam.supermarket/uimodule/package.json file:

,
		"test-runner": "ui5-test-runner --url http://localhost:4004/uimodule/test/testsuite.qunit.html --report-dir webapp/report"

2. Start the ui5-test-runner

To start the ui5-test-runner, we need to start the project as usual from the project root, including the backend server.

➡️ Run the following command from the codejam.supermarket/ directory:

# make sure you are in the codejam.supermarket/ directory (project root)
npm run dev:server

➡️ Open a new terminal (don't reuse the other one!) and run the following command from the codejam.supermarket/uimodule/ directory to start the tests:

# make sure you are in the uimodule/ directory
npm run test-runner

You'll notice how the tests are being executed headless. Feel free to inspect the test results at http://localhost:4004/uimodule/report/report.html.

report

3. Setup Code Coverage

As we are using the ui5-test-runner, code coverage can also be supported for testing. There's a quite good documentation available about enabling coverage reporting.

➡️ Just check out the following page: https://github.com/ArnaudBuchholz/ui5-test-runner/blob/main/docs/coverage.md.

Continue to Chapter 09 - Deployment