Test-driven development in
with BabyMock 2

Attila Magyar
FOSDEM 01/02/2014
Brussels
Who am I?

Attila Magyar
●

Java for living

●

Smalltalk for joy, since 2012
●

●

Python, Groovy, Lisp, etc..

TDD for a...
Agenda

●

●

●

About TDD and Mock objects in general
About BabyMock 2
● Differences between the new and the old version
...
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
Expect Message 3
●
Exactly once
●
With x argument
●

Outside-in TDD with Mocks

MOCK B
3
age
ss
Me

Message 2

Allow Messa...
BabyMock is a visual mock object library
http://smalltalkhub.com/#!/~zeroflag/BabyMock2/

Get a good mental picture of the...
The old syntax (BabyMock 1)
The new syntax (BabyMock 2)
Expectations
Under the hood
How does it work?
●

●

●

Mock object is a Proxy that intercepts all messages
Using the doesNotUnderstand is easiest way ...
BabyMock visualized with BabyMock
BabyMock visualized with BabyMock
BabyMock visualized with BabyMock
DEMO

ShoppingCart
●

Adding new item ids

●

CreditCard

●

Paying for its content

●

PriceCatalog
Food for thought

●

http://jmock.org/
(https://github.com/jmock-developers/jmock-library)

●

Evolving an Embedded Domain...
Upcoming SlideShare
Loading in …5
×

TDD with BabyMock 2

642
-1

Published on

BabyMock is a visual mock object library for Pharo Smalltalk, that supports test-driven development.

http://youtu.be/xChlI4j4Euc

Published in: Technology, Education
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
642
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
3
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

TDD with BabyMock 2

  1. 1. Test-driven development in with BabyMock 2 Attila Magyar FOSDEM 01/02/2014 Brussels
  2. 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. 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. 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. 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. 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
  7. 7. The old syntax (BabyMock 1)
  8. 8. The new syntax (BabyMock 2)
  9. 9. Expectations Under the hood
  10. 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.
  11. 11. BabyMock visualized with BabyMock
  12. 12. BabyMock visualized with BabyMock
  13. 13. BabyMock visualized with BabyMock
  14. 14. DEMO ShoppingCart ● Adding new item ids ● CreditCard ● Paying for its content ● PriceCatalog
  15. 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.

×