This is the 13th Testing Tuesday episode. Every week we will share our insights and opinions on the software testing space. Drop by every Tuesday to learn more! Last week was a special episode about Euruko 2013 with statements from many of the speakers.
Let Bogus check your contracts
If you have not seen our previous screencast on Bogus I would suggest that you have a look at episode 11, where we already had a look at it. There we found out that Bogus checks that your mocked classes and your stubbed methods actually exist. This way Bogus made sure that we didn’t stub any method calls that weren’t implemented. We ended up having empty method stubs for all our mocked behavior, but Bogus can do more: Bogus implements a concept called contract tests.
Whenever you stub a method with certain arguments and return values, Bogus can remember it and remind you to implement tests for your stubbed methods with exactly these arguments and return values. Bogus verifies that you only stub real method calls. There must be a context in which the stubbed method acts the way you stubbed it, or Bogus will fail your tests. Therefore Bogus checks the contract between mocked components – something that you would usually use integration tests for.
In this screencast we get started with Bogus’ contract testing. We walk step by step through implementing stubbed methods the way Bogus tells us too, and we will evaluate if Bogus can replace your integration tests. By the way: James Bond graces us with his presence again (!)
Have you done contract tests with Bogus before? What do you think of it? Let us know in the comments and share your experience!
Up next Testing Tuesday: How to set up RSpec
One thing we’ve always taken for granted in previous episodes was that our Ruby application was already set up with Cucumber and RSpec. In next week’s episode we will show you how you can integrate Cucumber and RSpec into your existing Ruby applications.
Want to build tools for other developers and join a well funded startup? Join us and bring Continuous Deployment to every software team. We are hiring!