CategoryTest Driven Development

Mockito – ArgumentMatcher vs ArgumentCaptor

M

Since a few weeks the new mockito release candidate is available. So I think it is the right time to place a new post. Here I will show the differences between ArgumentMatcher and ArgumentCaptor. Most developer will first see the ArgumentMatcher and use it. What can be done with ArgumentCaptor is often not seen. With the sample I will show that an ArgumentMatcher should not be used to fetch arguments. For this work there is the ArgumentCaptor. The Matcher should really be used to check if an...

Refactoring in Test Driven Development

R

cross-post from www.bbv.ch/blog
In the last two years I gave over a dozen courses and presentations about test driven development (TDD). One question, I get asked almost every time, is how to refactor code while keeping up the TDD rules:

write only production code if there is a failing test requesting it
have no more that one failing test at once

How to Unit Test Finite State Machines

H

We use a lot of state machines in our projects. We use them for abstracting instruments that we control, controlling when user input controls have to be enabled or disabled and for other things. State machines are great for these kind of tasks (much easier that nested switch statements anyway) but they provide a big challenge when developing software test driven. This is due to the fact that they are of course very state full and often active (running on their own worker thread). Here are some...

Why test naming conventions are important!

W

I’m working in an agile software development team which develops a fairly complex automation system for manufacturing facilities. We are using Test Driven Development as our main tool to improve the overall quality of the code. We all knew that we are going to have a large number of unit tests during the life cycle of the software. Before we started writing unit tests we decided that we need a test naming convention.

Clean Code and Clean TDD Cheat Sheets

C

Updated: new version here! I have compiled two cheat sheets about clean code (the ones mentioned in my post about Code Quality!). The first covers clean code – code that is easy readable and keeps changeable. The second is about Test Driven Development. Both cheat sheets list principles, patterns, practices and smells. You can download them here – Clean Code Cheat Sheet V1.3, Clean TDD Cheat Sheet V1.2. Take a look! I’d like to read your feedback in the comments section… (just an...

Create mocks with mockito

C

This is a small summarization what the differences are between the different variations creating mocks with mockito. Null values (default) Per default, after creating a mock, every method will return null. Just create your mock with: I think, this is very useful and straight forward. (And based by mockito developers idea, to create very fast a mock for testing). Sometimes it is very difficult to determine an error which was produced through such a null value. For this case it is very...

Recent Posts