Tuesday 17 November 2015

Practical GUI testing using SikuliX

Rejoice with me - after much banging of head against various walls, I have finally succeeded in building a GUI test out of Java, jUnit, Gradle and SikuliX 1.1.0. It starts a new game in the Mac OS Chess application, enters the opening move using drag/drop, and quits the application (answering correctly in the "save" dialog).

The secret was to give up on the idea of using the Python test script fragments created in the SikuliX IDE directly. Rather, I now translate these scripts line by line into Java; e.g. from
wait("xyz.png")
to
screen.wait("xyz.png");

Each short Python script is converted to a simple method on an object representing the application or individual screen under test. These methods can then be invoked as fixtures from any test framework, e.g. jUnit or Fit. The resulting test suite is built with Gradle and can be run as a standalone application to test the target application end-to-end.

One of the tricky bits was to set the image search path correctly so that the images embedded in the jar file can be located by the SikuliX API, whether you're running in the IDE or standalone. By storing a dummy SikuliX script within the src/main/resources folder (e.g. images.sikuli) you can use the SikuliX IDE directly to capture and fine-tune images for use in your tests.

Depending on the CI environment of the project, another tricky part may be to provide both the application under test and the test suite with a graphical pseudo display on which to run, but there is quite a lot of advice in the SikuliX documentation as well as on Stack Overflow about that.

Next steps:

  • Test this approach under Windows and Linux too
  • Enable the use of FIT in place of jUnit (more appropriate for whole-system tests)
  • Make use of the optional Tesseract library to read back values from the screen
  • Build and run test suite in various CI environments

Saturday 14 February 2015

The end of FM Radio?

A matter which concerns me greatly at the moment is the impending switch from FM to DAB radio, which could happen in the UK as soon as 2016. In 2013, communications minister Ed Vaizey announced a postponement of the digital switchover to "after 2015", following public pressure.

Manufacturers of broadcast and receiving equipment are naturally keen to sell lots of shiny new kit. Ironically, there are technically superior alternatives to DAB already available. The technology is over 20 years old and was superseded by the incompatible DAB+ system in 2007. Canada has already abandoned DAB entirely. Here are some of the things wrong with it:
  • The level of coverage leaves a lot to be desired - currently it is thought that 9% of the country will not have adequate DAB reception by the end of 2016
  • The quality of DAB leaves a lot to be desired. We have a couple of DAB radios in the house and usually leave them tuned to FM because the quality is better
  • DAB is not suitable for reception in a moving car
  • There is a random digitisation delay, meaning that the "pips" are not accurate enough to set a watch by. If you have radios in different rooms tuned to the same station, there's a ghastly "echo" effect because each radio has a different delay factor
Most households in the country will have to have to junk hundreds of pounds' worth of perfectly functional equipment. That's in effect a stealth tax and very bad for the environment. Many radio stations, some of which are run on a shoestring, may be forced to close down as they cannot afford the investment in new equipment.

It was bad enough when analogue TV ended, but at least the digital alternative was of better quality and there were add-on Freeview receivers available at a reasonably low price to adapt existing equipment.

If there's a technology that is really superior to FM radio, it should succeed on its own merits in the marketplace and not by regulation. Let's put more pressure on the government to postpone the FM switch-off indefinitely. I cannot find any on-line campaigns or petitions currently running to keep FM radio, but it could become an issue in the May 2015 UK General Election if enough of us raise the subject.