Today I read this blog post about how to simplify test data preparation. The author of the blog post states that setting up test data for tests is sometimes difficult and bloats up the test code, resulting in bad readability and maintainability. I completely agree with that. The author continues by solving this problem by loading the test data from a file and using it in the test. That minimizes the code needed to set-up the test data, but results in a disconnect between the test and the data...
FakeItEasy and Windows Store Apps are becoming friends
Probably you already know it: The new Windows Store App class libraries prevent proxy generating using frameworks like Castle.Core because System.Reflection.Emit namespace is missing in the limited framework they’re using.
But we still want to do TDD and therefore we need a nice mocking framework, like FakeItEasy, don’t we?
In this blog post I will show you the best way I came up with to develop Windows Store App compatible code with TDD.
Create your own hamcrest matcher
If you are familiar with hamcrest and JUnit the time will come when you have the need to create your own matchers. Creating your own matcher can be as simple as useful. One reason for creating your own matcher could be that your object is not a default object like a String or a Collection. And if you would like to get a more readable version of the assert for the next developer who has to read your test. Let’s make an example. If you have an object with two methods; “getName”...
No more development, TDD begins with MoreUnit
Do you program or do you already TDD? 🙂
If you prefer to do TDD you will love the eclipse plug-in called MoreUnit. It is as simple as powerful. All it does is executing tests from corresponding productive class and makes it very simple to change between them.
Just press Ctrl-J (like Jump) to jump from test to implementing class and the other way. Or press Ctrl-R (like Run) to run the test regardless if you are in the test or the implementation class.
Mockito – ArgumentMatcher vs ArgumentCaptor
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
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
Clean Code and Clean TDD Cheat Sheets
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...
Mockito – Answer vs. Return
Did you had the problem your mock must act like a bean? And you could not create the object with the real implementation? And the interface was too large, so you would not create a innerclass for the test? I had this problem too. I solved it with the answer in mockito.
Speaking at BASTA! in Mainz (Germany) on September 21st 2010
I’m going to speak about code quality (see my short version of the presentation) at the conference BASTA! BASTA! is mainly focused on .NET technology and gives you the opportunity to see and speak with a wide range of technology experts. If you have any feedback of what you are missing in my short presentation, please write a comment here or on the post with the presentation. The short version takes about 30 minutes and my speak at BASTA! is scheduled for 1 hour and 15 minutes. I will...
Create mocks with mockito
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...