Archive

Posts Tagged ‘java’

Maven completion in zsh

2009/09/22 2 comments

To get mvn completion in zsh, add this to your .zshrc:

function listMavenCompletions { reply=(cli:execute cli:execute-phase archetype:generate compile clean install test test-compile deploy package cobertura:cobertura jetty:run -Dmaven.test.skip=true -DarchetypeCatalog=http://tapestry.formos.com/maven-snapshot-repository -Dtest= `if [ -d ./src ] ; then find ./src -type f | grep -v svn | sed 's?.*/\([^/]*\)\..*?-Dtest=\1?' ; fi`); }
compctl -K listMavenCompletions mvn

It should complete the class names after ‘-Dtest=’, so that you can test one class at a time.

Categories: programming Tags: , ,

Maven, Junit4, Mockito and Anonymous classes

2009/04/10 Leave a comment

Mockito has a rather useful feature, answers, to allow you easily implement quick tests for objects that rely on behaviour of their dependencies:

when(mockFactory.createSomething()).thenAnswer(new Answer() { public Object answer(InvocationOnMock i) {
    someWork();
    return mockThing;
}});

However, Junit4 fails to initalise the anonymous class and run any tests on it, reporting errors. There is an @org.unit.Ignore annotation that you can use if you are prepared to make the anonymous class a nested class, but I can’t work out where to put the annotation on an anonymous class. How irritating, and I guess I’m not the only one.

Categories: programming Tags: , ,
Design a site like this with WordPress.com
Get started