Thomas Sundberg

September 4, 2016

Why should you care about quality?

Filed under: Automation, Quality, Technical debt, Test Automation — Tags: , , , , — Thomas Sundberg @ 21:48

This post is available at

November 6, 2015

Different asserts are good in different situations

Filed under: Java, Teaching — Tags: , , , — Thomas Sundberg @ 11:49

This post has been migrated to

When should you use which assert? It is a question developers new to unit tests may ask themselves.

It is easy as a seasoned developer to think that this is obvious. It isn’t when you are learning.


October 27, 2015

When is evolutionary design a good way to implement software?

This post has been migrated to

Designing software can be done in different ways. The time and effort spent on designing have an important effect on the result. An interesting question is: When should you allow the software to evolve using Test Driven Development, TDD, and when should you not?

Software Development Gang

This blog post is the result of a session at an open space with the Software Development Gang in Ghent, Belgium, June 2015.


April 28, 2015

Stubbing a var arg method using Mockito

Filed under: Gradle, Java, Mockito, Programming, TDD — Tags: , , , , , , , — Thomas Sundberg @ 23:28

This post has been migrated to

I had a need to stub a method the other day that had a var arg method. I failed in stubbing it using Mockito. It disturb me a lot. But after mulling on the problem a while, I searched and found a simple solution.

Mockito has a anyVararg() method that you should use when you try to stub a method that takes a var arg as argument.


April 24, 2014

Passing non primitive objects as parameters to a unit test

Filed under: Java, Programming, TDD — Tags: , , — Thomas Sundberg @ 20:40

This post has been migrated to http: //

How can you pass a parameter to a unit test parametrised with JUnitParams? The answer is simple: As any other parameter.


March 30, 2014

Why Cucumber?

This post has been migrated to

Before I can try to motivate why you should use a tool, let me define what it is and what it does.

What is cucumber?

Cucumber is a tool for collaboration and testing. It is used to create examples of behaviour that are executable. Creating examples in a collaborative way emphasize close cooperation between business analysts, testers and developers. The examples they come up with can be used as acceptance tests for the system being developed. It can be used as a testing tool where the tests are defined in a business friendly language while still being executable.


Our goal is to create a common understanding of the problem and therefore simplify the communication between all parties involved. We would also like to get something that is possible to use for automating the verification of the resulting program. That is, use as a base for test automation of the system.


December 28, 2013

Parametrised unit tests

Filed under: Programming, TDD — Tags: , , , , , — Thomas Sundberg @ 16:15

This post has been migrated to

Writing unit tests that test almost the same thing may introduce duplication. A solution could be to create parameters that should be varied in a list and iterate over it. Yet another solution is to create a parametrised test. Let us look at an example where these three options are explored.


August 21, 2012

Separating tests in Maven

This post has been migrated to

The way Maven file structure is defined is a great way to separate unit tests and production code. Unit tests are fast. So fast that developers developing using Test Driven Development, TDD, doesn’t have any performance problems when applying the Red-Green-Refactor cycle in their work. A large unit test suit is expected to be executed in seconds.

There is, however, no standard on how the files should be structured for slower tests (integration/acceptance/system A common property for these tests is that they are slow. They often require a complete system setup in a known state. They use the filesystem, network, database and similar slow resources. Slow tests are normally not executed often. Developers seldom have the patience to wait for a build a long time before writing the next thing. Using them in a Red-Green-Refactor cycle is not practical. It takes too long time.

So what options do we have to separate the fast units tests and the slow tests? There are two main tracks that I have explored.

  • Separating tests with name or package conventions
  • Separating slow tests in a test module


March 7, 2012

What is a good test?

This post has been migrated to

A colleague asked that question the other day. What is a good test? It is a really difficult question to answer. There are a number of properties that hold true for a good test. I will list some of them and discuss why I think they are important. Others may think that the order of importance is different or that other properties are more important then those that I list.

I will show some examples using Java and JUnit of what I think are bad tests and how they can be refactored to something better.

Tests are automated in my world. I always try to avoid manually testing. The main reason for this is that manual testing is slow and hard to repeat arbitrary many times. Therefore, test should be read as automated test in for the rest of this text.


November 29, 2011

The simplest possible solution

Filed under: Agile, Clean Code, Java, Programming, Software Craftsmanship, TDD, Teaching — Tags: , — Thomas Sundberg @ 22:02

This post has been migrated to

The simplest possible solution that could work. Ever heard that expression? What does it mean? Really?

The answer is obviously something that in a really simple way satisfies the test you currently are working on. Nothing more, nothing less.


Older Posts »

Create a free website or blog at