Friday, April 27, 2012

Using sandboxing in your tests

As you know mocks aren't stubs: stubs are used to return canned data to your system under test, so that you can make some assertions on how your code reacts to that data. Mocks, on the other hand, are used to specify certain expectations about how the methods of the mocked object are called by your system under test. But you should still use a mock library or framework even when you want to use stubs, because these libraries make it very easy to instantiate and work with stubs.

Recenlty I've discovered another interesting approach. It's provided by the tl.testing package that allows to sandboxe of directories and files. Here is my example. This code implements a search for a given string in files. I use doctest to check the functionality.


No comments:

Post a Comment