This post is available at http://www.thinkcode.se/blog/2016/09/01/why-should-you-care-about-quality
September 4, 2016
November 6, 2015
This post has been migrated to http://www.thinkcode.se/blog/2015/11/06/different-asserts-are-good-in-different-situations
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
This post has been migrated to http://www.thinkcode.se/blog/2015/10/27/when-is-evolutionary-design-a-good-way-to-implement-software
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
This post has been migrated to http://www.thinkcode.se/blog/2015/04/28/stubbing-a-var-arg-method-using-mockito
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
This post has been migrated to http: //www.thinkcode.se/blog/2014/04/24/passing-non-primitive-objects-as-parameters-to-a-unit-test
How can you pass a parameter to a unit test parametrised with JUnitParams? The answer is simple: As any other parameter.
March 30, 2014
This post has been migrated to http://www.thinkcode.se/blog/2014/03/30/why-cucumber
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
This post has been migrated to http://www.thinkcode.se/blog/2013/12/28/parametrised-unit-tests
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
This post has been migrated to http://www.thinkcode.se/blog/2012/08/21/separating-tests-in-maven
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 et.al.). 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
This post has been migrated to http://www.thinkcode.se/blog/2012/03/08/what-is-a-good-test
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
This post has been migrated to http://www.thinkcode.se/blog/2011/11/29/the-simplest-possible-solution
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.