The problem I was having when running SWTBot tests in Travis CI was that I could not use the new container-based infrastructure of Travis, which allows to cache things like the local maven repository. This was not possible since to run SWTBot tests you need a Window Manager (in Linux, you can use metacity), and so you had to install it during the Travis build; this requires sudo and using sudo prevents the use of the container-based infrastructure. Not using the cache means that each build would download all the maven artifacts from the start.
Now things have changed 🙂
When running in the container-based infrastructure, you’re still allowed to use Travis’ APT sources and packages extensions, as long as the package you need is in their whitelist. Metacity was not there, but I opened a request for that, and now metacity is available 🙂
Now you can use the container-based infrastructure and install metacity together (note that you won’t be able to cache installed apt packages, so each time the build runs, metacity will have to be reinstalled, but installing metacity is much faster than downloading all the Maven/Tycho artifacts).
The steps to run SWTBot tests in Travis can be summarized as follows:
# - sudo apt-get update
# - sudo apt-get install metacity
- sh -e /etc/init.d/xvfb start
- metacity --sm-disable --replace 2> metacity.err &
I left the old steps “before_install” commented out, just as a comparison.
- “sudo: false” enables the container based infrastructure
- “cache:” ensures that the Maven repository is cached
- “env:” enables the use of graphical display
- “addons:apt:packages” uses the extensions that allow you to install whitelisted APT packages (metacity in our case).
- “before_script:” starts the virtual framebuffer and then metacity.
Then, you can specify the Maven command to run your build (here are some examples:
Happy SWTBot testing! 🙂