Testing a Scout Application with JUnit and Jubula
Writing tests is one of the best practices of software development. This talk presents three ways to test a Scout application: plain JUnit, JUnit within an OSGi context, and in combination with service mock and black-box UI testing with Jubula.
JUnit is probably one of the most well-known tools in the Java community. For plugin based applications, it is a good practice to store the test code in a separate test plugin or in test fragments (which lets you use the same class loader and also lets you access internal packages). This variant is useful for testing small units of code without any other dependencies.
A framework like Eclipse Scout relies on OSGi for its dependency lookup mechanism. Without an OSGi context, a call to SERVICES.getService(..) in the Eclipse Scout code will return null, producing ugly null pointer exceptions. The Eclipse Scout Framework provides a small extension to JUnit: a specific runner that ensures that the OSGi context is loaded before the tests are executed. This may slow down the test execution, but it also opens up new perspectives. For example it is possible to exchange a real service (a call to the server) with a mocked one. The test becomes decoupled from the real service implementation and it is possible to test the code against different responses of the service.
The third testing variant we want to present is UI black-box tests with Jubula. The aim of tests at this level is to ensure that the workflows and use cases that the user requires can be performed correctly. One of the advantages of using Jubula is the ability to write the automated tests before the application is ready - using e.g. prototypes, specifications, mockups and team discussions for information. As well as clearing up misunderstandings early on in the development process, this also means that the tests can run against the application as soon as a version is available and therefore provide timely feedback.
In the presentation, we show examples to test a simple Scout application. A single form application is introduced at the beginning of the talk. The talk combines theory (introduction of testing concepts) and demonstration based on examples with real code.