Yes I am mocking you

Agile development practices may seem easier for small, isolated teams, but what happens in the real world when applications go across teams and dependencies to rear their ugly heads?  The answer I hear too often is ‘adjust in your planning sessions so that the dependencies go away.’  That’s not a real, complete solution to me.  Here is why – that answer makes sense if we are creating an application and we have two stories – Add item to shopping cart and Remove item from shopping cart for example.  In this case it’s logical to plan accordingly.  We wouldn’t want to release the product without being able to add items, and this functionality seems in control by the team.

 

What about this more common example though – a front end team develops an application that depends on data from a data team.  On top of that, not only does the front end team depend on the data team, but so do 3 other teams, all with different priorities and needs.  And since it is the real world, we have a deadline to hit – the application needs to launch in 6 weeks and the data team won’t be able to finalize the data for the front end team for 4 weeks.  It doesn’t make sense for the front end team to not work, especially if the amount of time they need is greater than the remaining two weeks.  What do you do?

 

There isn’t a simple answer to this.  You don’t get to wave the magic Agile wand and voila – problems solved.  Yes, ‘push the date’ may be the easy out, but that isn’t always possible or even recommendable.  TDD leveraging Mocks won’t solve this problem, but it will allow teams to continue working, deferring those dependencies to as late in the game as responsible.

 

What are mocks? A mock is a fake representation of an object (in this case an object that might not exist or be implemented yet) that developers can use and manipulate in a controlled fashion to allow them to continue testing.  Using the example above, the front end team has a set of data they need.  Presumably there is an object that represents that data and a service around retrieving that data.  The front end team in this scenario would mock the data object. That data object would be volatile (still under development by the data team) but the front end team would want to be able to create their own tests which would be dependent upon it.  Enter mocks. This way the front-end team would be able to stress different interactions with the data without having the data layer delivered.

Mocks do not replace communication in the software development process.  If the front end team does not speak with the data team, it is very well possible that the data they get won’t even be the data they need, even with great tests around it. Mocks are successful when dependent agile teams work together to understand their interactions and can agree on some interfaces or test contracts. This allows the teams to continue their work in parallel.

 

Ready to get your hands dirty? Here are some great links:

 

googlemock – Google C++ mocking framework

EasyMock – mocking framework for Java –  Great EasyMock example by Michael Minella

Mockito – mocking framework for Java — Great Mockito example by Brett Schuchert

Rhino - mocking framework for C# — Rhino example by Isiah Perumalla

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值