Show TOC

Step 10: Test Suite and Automated TestingLocate this document in the navigation structure

In this step, we will step back from our tests and application features that we have implemented so far and add another important piece of test code: The test suite page. A test suite can execute multiple tests and collect the results. This comes in handy for automatic tools in a continuous integration process.

Figure 1: A Selenium runner for the test suite of the bulletin board

You can view and download all files in the Explored app in the Demo Kit under Testing - Step 10.

webapp/test/testsuite.qunit.html (New)
<!DOCTYPE html>
	<title>QUnit TestSuite for Bulletin Board</title>
	<script type="text/javascript" src="/resources/sap/ui/qunit/qunit-redirect.js"></script>
		 * Add test pages to this test suite function.
		function suite() {
			var oSuite = new parent.jsUnitTestSuite(),
				sContextPath = window.location.pathname.substring(0, window.location.pathname.lastIndexOf("/") + 1);
			oSuite.addTestPage(sContextPath + "unit/unitTests.qunit.html");
			oSuite.addTestPage(sContextPath + "integration/opaTests.qunit.html");
			return oSuite;

The coding is quite straight-forward, we require the relevant QUnit files for redirecting to the central test suite and provide a configuration function suite() that is called automatically by the testrunner.

Inside this function we add the QUnit pages for the app’s unit and integration tests. For technical reasons, we have to provide an absolute path to the HTML pages so that the testrunner can execute them centrally. You can now run the webapp/test/testsuite.qunit.html file to check if all unit and integration tests are running fine with one URL.

A similar test suite can be configured as a pre-commit hook in local build environments or as a pre-submit hook in a continuous integration scenario on the central build server. Only when all tests run successfully, a new change is accepted and may be merged.

Alternatively you can use a local test runner, such as Selenium or Karma, that automatically executes all tests whenever a file in the app project has been changed. All of these configurations run the tests and collect the resulting messages for further analysis. Therefore, it is very important to define meaningful test descriptions and success as well as error messages as you write your application tests.

  • Create a test suite app that triggers all your tests at once

  • Run the test suite whenever you change the code of the app