Blog Archives

Great Expectations

What’s the best way to handle expected exceptions in JUnit? If you want to inspect the contents of the exception and make assertions against it then there is only one clean way; Use the ExpectedException JUnit Rule. I’ve seen it

Posted in Clean Test Code, Hamcrest, JUnit, JUnit Rule

Reusable Test Utility Code and Maven

I often see almost identical bits of code copied and pasted in test classes spread throughout different packages, even different modules. Sometimes someone will bother to create a reusable utility class that is called from different tests, but then someone

Posted in Clean Test Code, Maven

JodaTime and JUnit

JUnit Rules are powerful things. There are all sorts of things you can do with a Rule that makes test code cleaner and less error-prone. Because a Rule wraps the test method, it’s really useful for things that need both

Posted in Clean Test Code, JUnit, JUnit Rule

Flexible Mocking

Unit tests, in particular the assertions within, should be no more and no less specific than they need to be. Make a test too loose, and it will be possible for someone to make changes to the code in a

Posted in Clean Test Code, EasyMock

How to write a Jenkins Plugin – Part 4

In this part we’ll look at getting your plugin hosted on the Jenkins GitHub, performing a release, and documenting your plugin in the Jenkins wiki. Your main point of reference for this should be the official guide in the Jenkins

Posted in Jenkins, Jenkins Plugins

How to write a Jenkins Plugin – Part 3

In this part we will find a way to count the number of failed jobs in a view and pass it back to our Jelly UI fragment. Counting Failed Jobs In a View First we’re going to modify our viewTabs.jelly

Posted in Jenkins, Jenkins Plugins

How to write a Jenkins Plugin – Part 2

In this part we will create a form fragment for the global config page using Jelly, and see how to save and use changes to the config submitted by users. Then we’ll customise the view tabs Jelly to call our

Posted in Jenkins, Jenkins Plugins

How to write a Jenkins Plugin – Part 1

Maven Settings You will need Maven 3 for this. Maven 2 will not work. (Also needs JDK 6 or higher.) You will need to add some junk to your settings.xml: In pluginGroups add <pluginGroup>org.jenkins-ci.tools</pluginGroup> And In profiles, add a profile like

Posted in Jenkins, Jenkins Plugins

How to write a Jenkins Plugin – Introduction

Why? I love Jenkins. Use it all the time. Depend on it, rely on it. Wherever I work, I always make considerable and sustained efforts to improve the way that Jenkins is used. Extending from commit builds to complete delivery

Posted in Jenkins, Jenkins Plugins

JUnit Rule for Annotations in EasyMock 3.3

In my first contribution for EasyMock 3.3 I have added support for processing the annotations with a JUnit Rule instead of the JUnit Runner. In 3.2 you could do this: @RunWith(EasyMockRunner.class) public class SomethingTest extends EasyMockSupport{ @Test public void shouldDoSomething()

Posted in EasyMock, JUnit