Mocking Resources using JUnit @Rule

When writing unit tests in Java there might be the need to access a resource in the class that should be tested. A common way is to mock the resource. But mocking a simple resource is quite easy. This is supported by mocking frameworks like Mockito, EasyMock or PowerMock. It is a good idea in case you want to test a single action on the mocked resource – e.g. returning a value when accessing a map that contains master data. The following exmaple describes mocking a resource using Mockito. But in case there are complex operations on this resource mocking it is going to be really nasty.
Continue reading →

Welcome to block zero

In this blog I’m trying to write some stuff about software development (Java/JavaEE in special), Linux and other IT related topics. I intend to post only those things that describe the difference to standard, as well as all those little things that help to give exactly the improvement you need to get a really good solution working.

I hope I will be able to post also some stuff around technical development and its influence to society. Maybe there might some interesting topic that is worth to be written down 😉

I hope you enjoy block zero.