Mockito Tag

As a software developer you will use plenty of frameworks during your career. There are the big beasts like Spring, ActiveMQ or OSGi that you have to master in order to build the foundations of your applications. And then, there are the small frameworks. Let's call them lightweight tools. Like a carpenter, the lightweight tools are kept in a toolbox. The carpenter will use industrial...

Read More

In some of my previous posts I've talked about well-crafted code. I'm really convinced that software development is a craft - but what does that mean? The "Manifesto for Software Craftsmanship" contains the following 4 points: Considering these points I took a look at the EclipseCon Europe 2012 session schedule and picked out a view talks I would like to attend. Maybe they are a good...

Read More

I've been using the Android framework RoboGuice 2.0 a lot lately. RoboGuice is an extension for the Google Guice dependency injection framework that adds several Android specific mechanisms to easily inject views, services or custom objects. Coming from an OSGi background, it is interesting to see how much deeper Guice is able to be interwoven into the Java code when your entire project is composed of...

Read More

It is not a secret that we are big fans of Mockito at EclipseSource. Our Java mocking framework of choice has helped us in many projects to stay on the test driven development path. Luckily we are also able to apply these same principles when developing Java code on Android. Although Mockito is great for mocking Java classes, it would sometimes be very cumbersome to mock...

Read More

With this effective Mockito Post I want to share a really simple pattern with you. We call this pattern "check answers" and we use it whenever we work with Mockito Answers. The code resulting from creating Mockito Answers generally looks ugly. But, as good programmers we care about test quality, right? :) Let's see how we can make better looking answers using the "check answer" pattern....

Read More

This Effective Mockito Post will be IDE specific again but related to the last post on Mockito's spies. If you've read Part 3 you should now be familiar how to use them to "pseudo mock" statics. When writing code it often comes to a point where we want to debug using single step debugging. When using Mockito and especially when spies come into the game...

Read More

In the previous Effective Mockito post we saw how to use the @Mock Annotation to get a clean test. In this post I want to show you how to use Mockito's spy mechanism to eliminate testing troubles with third party libraries. Testing is one of the most important things in software development. I assume you agree with me because you decided to read this blog post...

Read More

As promised in the first part of the "Effective Mockito" blog series, I will concentrate on Mockito specifics in the followup posts. So, the main topic for Part 2 is Mockito's @Mock Annotation. When I write tests I try to follow an explicit pattern, called the build-operate-check pattern. This was described by Uncle Bob in his book "Clean Code" (Page 127, Chapter 9). The main idea...

Read More

Last week I talked to a fellow developer, Frank Appel, about Mockito. We've been using this mocking library for over a year. We both agreed that of all the innovations we've tried in the last year or so, Mockito has boosted our coding productivity the most. With this blog series we want to share our experiences with Mockito. You see that I used the word...

Read More