Learn to Stop Worrying and Love the Singleton

Fredrik Olsson

Enterprise applications and mobile applications have quite different requirements. Starting an enterprise application is just something you do once before it continue running for months or years. On the other side of the spectrum most mobile applications seldom runs for more than minutes, run by a bored users standing in line or riding the bus. [...]

Tags: , , , , ,

Getting started with JavaME jUnit testing

Mattias Severson

Introduction
Unit testing is a very powerful tool that should be included in every developer’s toolbox. Unfortunately, this has not always been the case, especially not among MIDlet developers. One reason is that JavaME projects usually are small (compared to Java SE projects), which implies that manual testing could be enough. However, as soon as you [...]

Tags: , , ,

How to mock MIDP RecordStore

Mattias Severson

The challenge
PowerMock is a mocking framework that claims to have almost supernatural powers. According to its documentation it is able to mock both static and private methods, final classes, and other nasty things that would be insurmountable obstacles for other mock frameworks. As a result, it has been stated that it should be able to [...]

Tags: , , ,

Mocking Eclipse IResource.accept()

Tobias Södergren

I had a junit test situation where I wanted to mock an Eclipse IResource instance but still be able to test a call-back implementation given as parameter to the mocked IResource.accept(IResourceVisitor visit) method. By default, mocking an interface gives you “call count” and expected return values but no code is executed. In order to test the implementation of IResourceVisitor, something more had to be done. Here is how I did it.

Tags: , , ,

PowerMock 1.0 released

Jan Kronquist

We have released 1.0 of PowerMock just in time for the Øredev conference! PowerMock is an open source mock framework based on EasyMock that allow you to mock static methods, private methods and even constructors. Our intent is mainly to allow unit testing of legacy code and people really seemed to appreciate this idea at the conference.

Tags: , , , , ,

PowerMock 0.8 released

Johan Haleby

Previously a colleague of mine described an idea for mocking static methods. Earlier this year we started an open source project to implement these ideas in a very simple to use form. The idea is that it will just be a normal jar file that extends EasyMock and JUnit. Instead of using AspectJ we have [...]

Tags: , , , , ,

Mocking Classes

Ulrik Sandberg

Mocking a class rather than an interface might present some interesting obstacles. Perhaps you have ran into the dreaded:
Unexpected method call toString():
toString(): expected: 0, actual: 1
You think nothing of it and happily add an expectation for toString. Then you get:
Unexpected method call toString():
toString(): expected: 1, actual: 2
The reason is that EasyMock [...]

Tags: ,

Static Mock using AspectJ

Jan Kronquist

After seeing MockME developed by some of my colleagues I started thinking about how this could be made in a generic way.

Tags: , , ,