Archive

Posts Tagged ‘Mockito’

Mockito – Answer vs. Return

July 20th, 2010
Adrian Elsener

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.

read more

 

Java, Test Driven Development, Testing , , , , , ,

Create mocks with mockito

June 25th, 2010
Adrian Elsener

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:

Sample sample = Mockito.mock(ISample.class);

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 practicable to tell mockito, returning SmartNullValues.

read more

 

Agile, Java, Test Driven Development, Testing , , , , ,

Mockito

April 6th, 2009
Adrian Elsener

A few weeks ago, I started using Mockito. Mockito is a mocking framework for Java.

What mockito is able to do:
- mocking interfaces and abstract classes
- mocking concrete classes
- spy real objects

(http://code.google.com/p/mockito)

I liked mockito so much that I decided to present it to you…
read more

 

Java, Testing , , ,