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

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.

Wednesday, 15 October 2014

Simple, secure way to share a git repository

The problem with Windows or NFS file shares is that the contents are not version-controlled and (unless you use the Windows "available off line" feature) not available while you're disconnected from the office network. However, it is very easy to set up a git repository for a team to share code and documents, if they all have at least intermittent access to the same file share.

First install yourself a git command-line client if you have not done so yet (see http://git-scm.com/downloads).

Creating the repository

Assuming that
  • You already have a local git repository called "test-repo", which you want to share
  • Your local git repositories are under %HOMEDRIVE%\%HOMEPATH%\git
  • Your shared git repositories are going to be under \\myserver\myshare\git

To add a remote copy of your own git repository to the share:

>cd %HOMEPATH%\git\test-repo
>pushd "\\myserver\myshare\git"
>git init --bare test-repo.git
>git remote add origin "//myserver/myshare/git/test-repo.git"
>git push origin master

Note that the git commands require slashes to be forward - unlike normal Windows commands.

Verify that the file .git\config within your local git repository looks something like this:

    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true
    hideDotFiles = dotGitOnly
[remote "origin"]
    url = //myserver/myshare/git/test-repo.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master
    rebase = true

Ensure that the sections [remote "origin"] and [branch "master"] in particular are set up correctly.

Cloning the repository

Another team member can now share your code - you both push your local commits to the shared repository and pull other team members' commits from it to your local repository. Here's what each team member wishing to access the shared repository should do, assuming that they also have their local git repositories under %HOMEDRIVE%\%HOMEPATH%\git.

>cd %HOMEPATH%\git
>git clone "//myserver/myshare/git/test-repo.git" test-repo
>cd test-repo
>git pull
>git status

The status should look like this:

# On branch master
nothing to commit (working directory clean)

Making cycling safer!

I have just been alerted to the existence of Collideoscope - a service that aims to collect data about cycling accidents and near misses directly from cyclists, and use it to press for improvements to road safety at accident black spots. What a brilliant idea. You can also use it to educate yourself about areas in which to take extra care when cycling.

Friday, 17 January 2014

Carbon - the EU's chance to shine

I am really concerned that we may be causing irreversible and harmful climate change.

While there is no conclusive proof that humankind is behind global warming, the evidence against us is stacking up more and more heavily.

The planet has some amazing mechanisms for keeping the environment stable, such as soaking CO2 up in the oceans, but these are not infinitely flexible and we may be approaching a tipping point. As an illustration of this, consider a glass filled with water and ice cubes, standing in a warm room. The ice/water mixture stays at 0 degrees as the ice gradually turns to water, but once all the ice has melted the temperature rapidly rises.

While we have not proved that our wasteful use of fossil energy is causing global warming, there is ample evidence that using a lot less won't cause any harm and may in fact stimulate the economy. So it would be logical to reduce our emissions of both greenhouse gases and waste heat as quickly as possible.

More research is needed to identify renewable energy sources that are much more efficient and less environmentally damaging than wind turbines or biofuels. Better insulation and more efficient heating, manufacturing, agriculture and transport are also needed.

Right now, the President of the EU Commission, Jose Manuel Barroso, is weighing a decision that could make or break our planet. His team have just days to pin down carbon emissions and renewable energy targets for Europe until 2030. It’s a very important deal that has been kept very quiet. Some EU countries, prompted by vested energy interests, are lobbying to set extremely unambitious targets. Barroso may opt to avoid a fight by playing it safe. He works in a bubble of politicians, officials and lobbyists, but he is very sensitive to what people think of him, especially now as he embarks on his last few months in the job and hopes to leave a shining legacy.

Avaaz is publishing an ad in the key Brussels paper today calling on Barroso to follow the science. If supported by tens of thousands of e-mail messages from across Europe, this could just jolt him out of the bubble. You can read the ad and send Barroso a message today that the the future of the world is in his hands.

Monday, 8 April 2013

Music by Programmers - Launch Party

Jason Gorman and five of his programming chums have put together an album of original electronic music to raise money for educational programmes at Bletchley Park and The National Museum Of Computing. The charities get every penny of the profits, split 50/50 between them.

The album goes on sale in late April, and Jason's target is to sell 2,000 downloads and raise £10,000. The music industry isn't what it was, and selling music is much harder than it used to be - even for a good cause. Between now and the release date, they're going to need as much help as they can get to spread the word.
Please feel free to publicise their efforts by any means at your disposal.

A special listening party to launch the album on 23rd April is not to be missed. It's going to be small and intimate at a "jolly spiffy pub" near Holborn. Every penny of the £20 ticket price goes directly to Bletchley Park for maths workshops and a programming club at The National Museum Of Computing. And every ticket holder will get a very limited edition CD with bonus tracks!!! Only 100 of these special edition CDs will be produced, so it promises to be a veritable collector's item.

Saturday, 6 April 2013

GCalendar in Joomla: Daylight Savings problem

We recently launched a new Web presence for my German Church using Joomla 2.5. At my suggestion, GCalendar was installed to provide a searchable event calendar and an "upcoming events" module. It all worked splendidly until British Summertime began on 31 March 2013 - and suddenly all calendar events were shown starting an hour early.

We spent days trying to find a way to configure Daylight Savings into the calendar. All it allowed us to do in the global settings was to choose a time zone - of course we had set it to Europe/London - but without an option of respecting Daylight Savings automatically. In despair, I eventually uninstalled the component and reinstalled it. At this point there was a new version (3.0.0) of GCalendar available, so I chose that. In the component control panel there turned out to be an options button at the top right of the screen, which we may simply have missed seeing before. In the options you can set the time zone and once I had done so, suddenly all the times appeared correctly again within the web site. Huge sighs of relief all round.