2. Who am I?
Attila Magyar
●
Java for living
●
Smalltalk for joy, since 2012
●
●
Python, Groovy, Lisp, etc..
TDD for about 4 years
Contact:
http://twitter.com/zeroflag
3. Agenda
●
●
●
About TDD and Mock objects in general
About BabyMock 2
● Differences between the new and the old version
● How does it work?
● Few words about the internals
DEMO
4. Outside-in TDD with Mocks
B
3
age
ss
Me
Message 2
A
Me
ssa
ge
4
R
es
po
ns
e
Test
Message 1
C
5. Expect Message 3
●
Exactly once
●
With x argument
●
Outside-in TDD with Mocks
MOCK B
3
age
ss
Me
Message 2
Allow Message 4
● Any number of times
● With y argument
● Answer „Response”
A
●
Me
ssa
ge
4
R
es
po
ns
e
Test
Message 1
Inter-object protocol
MOCK C
6. BabyMock is a visual mock object library
http://smalltalkhub.com/#!/~zeroflag/BabyMock2/
Get a good mental picture of the objects relationships, and
the inter-object protocol
●
●
Identifying test failures is easier
10. How does it work?
●
●
●
Mock object is a Proxy that intercepts all messages
Using the doesNotUnderstand is easiest way to implement it
(but limited).
Nil methodDictionary + cannotInterpret
More information:
Efficient Proxies in Smalltalk by Mariano Martinez Peck et al.
15. Food for thought
●
http://jmock.org/
(https://github.com/jmock-developers/jmock-library)
●
Evolving an Embedded Domain-Specific Language in Java, Freeman, S. and Pryce, N.
●
Mock Roles, Not Objects. OOPSLA 2004, Freeman, S., Mackinnon, T., Pryce, N., Walnes, J.,
●
Growing Object-Oriented Software, Guided by Tests, Freeman, S. and Pryce, N.
●
Efficient Proxies in Smalltalk, Mariano Martinez Peck et al.