Running WindowTester Pro from Maven/Tycho

Running SWTBot tests as part of your maven/tycho build cycle is rather well documented and pretty straight forward (see for example the sonatype docs). Doing so with a WindowTester Pro recorded test is not – but then again it is pretty straigt forward as well.

There are just two things that you need to change from the SWTBot tests pom.xml (as presented in the sonatype docs):

  • have useUIThread = true
  • add a dependecy to com.windowtester.runtime.feature.group to pull in platform specific plugins

You will also need to tell maven/tycho where to find the latter feature, of course, by adding http://dl.google.com/eclipse/inst/windowtester/beta/3.7 to your repositories.

Full sample pom.xml after the break.
Continue reading

Running Tycho in Jenkins/Hudson

When I first started running my Tycho/Maven build of my visual editor in Jenkins the build would always fail if a single test failed. That was mainly because the Maven build would run the surefire test automatically but cancel the build if there were any failures in them. In turn, this would not keep artifacts from being generated and thus not create a new snapshot release. To make matters worse, my tests are not that stable yet – running them on Linux sometimes fails for no reason whatsoever, leading to yet another broken build.

Now, this is obviously not what you (or Jenkins, for that matter) would expect to happen. What I wanted and what I guess you would normally want is for the build to pass but for Jenkins to mark the build as “unstable”.

To acomplish this on the command line, you simply need to tell Maven to ignore test failures
mvn clean install -Dmaven.test.failure.ignore=true

With Jenkins, this is equally straight forward:

Now Jenkins acts nicely and reports unstable builds while still producing all artifacts.

vRest maven build finally working

I finally managed to get the Maven-based build of my Eclipse-based graphical editor to work – including unit and swtbot-ui tests:

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] de.van_porten.vrest.build ......................... SUCCESS [0.077s]
[INFO] de.van_porten.vrest.target-platform ............... SUCCESS [0.112s]
[INFO] de.van_porten.vrest.core .......................... SUCCESS [2.842s]
[INFO] de.van_porten.vrest.core.edit ..................... SUCCESS [0.869s]
[INFO] de.van_porten.vrest.core.editor ................... SUCCESS [0.829s]
[INFO] de.van_porten.vrest.bundle ........................ SUCCESS [0.105s]
[INFO] de.van_porten.vrest.help .......................... SUCCESS [0.076s]
[INFO] de.van_porten.vrest.ui ............................ SUCCESS [1.387s]
[INFO] de.van_porten.vrest.ui.properties ................. SUCCESS [3.650s]
[INFO] de.van_porten.vrest.feature ....................... SUCCESS [0.113s]
[INFO] de.van_porten.vrest ............................... SUCCESS [1:08.099s]
[INFO] de.van_porten.vrest.tests.core .................... SUCCESS [4.087s]
[INFO] de.van_porten.vrest.tests.ui ...................... SUCCESS [13.315s]
[INFO] de.van_porten.vrest.p2-repository ................. SUCCESS [2.498s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3:02.410s
[INFO] Finished at: Sat Nov 26 22:22:30 CET 2011
[INFO] Final Memory: 97M/231M
[INFO] ------------------------------------------------------------------------

I’ll push to Jenkins now and see if the continous build and test also works there. Cross your fingers.

The one thing that is bugging me is an oddness with my target platform defintion that for some reason doesn’t want to resolve org.apache.batik.* properly – once I switch target to the development platform everything works as expected. But I will figure that one out eventually ..

More on the culprits and solutions I have to follow shortly.

CUnit-to-JUnit transform now on BitBucket

One of the most visited blog entries on this blog probably is my article on transforming CUnit results to JUnit results: CUnit Tests in Hudson. There I write about how to use xsltproc to transform the output of CUnit to be processed by Hudson/Jenkins.

Now, I decided to put the file on BitBucket to maybe consolidate the contributions or changes others are making. I welcome everybody to make contributions to the transform there.

The link to the BitBucket project is: https://bitbucket.org/mcdeck/cunit-to-junit

Testing XMLRPC Controllers in Pylons

Testing is one of the essential tasks in modern software development, so it is only natural to want to test an application as thoroughly as possible.

I’m currently working on an application that offers a service via xmlrpc. For a client side implementaion I use python’s xmlrpclib and that is working well. Then again, I obviously want to test the xmlrpc functionality also during regular unit and functional tests and not only using the client. What’s more, having to instantiate a server to be able to run tests is cumbersome at best.

Unfortunatly, Pylons does not offer a method to test xmlrpc controllers out of the box. The solution I found is not quite as complicated as I had feared at first. Read more after the break.
Continue reading

Pylons and Apache with repoze.who BasicAuth

To be able to use Basic Authentification in repoze.who running in a wsgi app in your Apache installation, you need to tell Apache to WSGIPassAuthorization. An Apache configuration like this will do:

1
2
3
4
5
6
7
8
9
# Setup mod_wsgi
WSGIPythonHome /var/www/pylons/runtime
WSGIScriptAlias /myApp /var/www/pylons/myApp/mod_wsgi/dispatch.wsgi
WSGIPassAuthorization On
<directory /var/www/pylons/myApp/mod_wsgi>
Order deny,allow
Allow from all
</directory>

The importanat part here is

1
WSGIPassAuthorization On

This will pass HTTP authorisation headers through to the WSGI application.

Sources: Repoze-dev Mailing List, modwsgi Wiki

Generating Faults in Pylons XMLRPCController

This might seem easy enough, but it took me a while to get it right since the Pylons documentation is a bit misleading here, really. It says you should use xmlrpc_fault from pylons.controllers.xmlrpc but that’s actually not working if you’re doing something like:

Python
1
2
3
from pylons.controllers.xmlrpc import xmlrpc_fault
...
return xmlrpc_fault( 101, "My Error" )

This will wrap an xmlrpclib.Fault into a pylons.controllers.util.Reponse object which will fail to marshal with something like:

Python
1
2
TypeError: cannot marshal <class 'pylons.controllers.util.Response'> objects
</class>

The correct way to do it is:

Python
1
2
3
import xmlrpclib
...
return xmlrpclib.Fault( 101, "My Error" )

Django on Windows

To more easily use Django on Windows, create a dos .bat file in Django’s bin directory named django-admin.bat with the following content:

1
@%~dp0\..\..\..\..\python.exe %~dp0\django-admin.py %*

and add Django’s bin directory to your PATH:

1
2
set DJANGO_HOME=C:\Development\tools\Python25\Lib\site-packages\django
set PATH=%DJANGO_HOME%\bin;%PATH%

You can now use django-admin from anywhere without specifying the full path.

(I kept getting ImportError: No module named django.core when trying to invoke django-admin.py from the commandline)

Multiple Many-to-Many in Grails

Creating many-to-many relationships in Grails is quite simple. It is also possible to have multiple many-to-many relationships in a single class, but for some reason I found little documentation on how to do this. It is actually quite simple once you know how to and pretty much comes down to syntactic sugar, so to speak. Read more after the break.

Continue reading