Implementing MockFramework

5 views
Skip to first unread message

Gili

unread,
Oct 26, 2008, 2:17:52 PM10/26/08
to atunit
Hi Logan,

AtUnit looks quite interesting. I'm wondering if you could help me
understand how to implement MockFramework for Mockito. AtUnit passes
in a list of Fields and I'm supposed to return mock objects for them?

Also, I was wondering if you have the TestScope concept from
guiceberry, where each test uses its own injected instances.

Thank you,
Gili

Gili

unread,
Oct 26, 2008, 10:14:41 PM10/26/08
to atunit
Here you go:

import atunit.Mock;
import atunit.Stub;
import atunit.core.MockFramework;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
import org.mockito.Mockito;

/**
* Integrates Mockito into AtUnit.
*
* @author Gili Tzabari
*/
public class MockitoFramework implements MockFramework
{
@Override
public Map<Field, Object> getValues(Field[] fields) throws Exception
{
Map<Field, Object> result = new HashMap<Field, Object>();
for (Field field: fields)
{
if (field.getAnnotation(Mock.class) != null ||
field.getAnnotation(Stub.class) != null)
result.put(field, Mockito.mock(field.getType()));
}
return result;
}
}

Feel free to integrate this into AtUnit.

Gili

Gili

unread,
Dec 19, 2008, 2:35:04 PM12/19/08
to atunit
Just curious, did this make it in? :)

Gili

Guðmundur Bjarni

unread,
Dec 20, 2008, 8:03:26 AM12/20/08
to atunit
Hi Gili,

I don't know whether you checked out my Mavenizing effort, but I
integrated your addition into that as I'm using Mockito myself. :) In
case you want to check it out: http://github.com/gudmundur/atunit/tree/master

regards,
Guðmundur Bjarni

Logan Johnson

unread,
Dec 21, 2008, 9:48:19 AM12/21/08
to atu...@googlegroups.com
Not yet.  Good news though!   I'm on vacation and will be catching up on some AtUnit backlog tomorrow.  Hopefully I can just pull Guðmundur's integration work and merge it.

Clearly I need to find a way to remove my availability as a bottleneck on AtUnit's progress.  (And get AtUnit 2 finished and out the door.)
Reply all
Reply to author
Forward
0 new messages