May 27, 2013

mocking frameworks

In the next several subsequent posts I want to revise mocking frameworks available today, describe key features, provide examples and compare with alternatives.

Mock-objects are usually used in unit-tests to separate the object under test from its dependencies. Unit-tests are supposed to test objects independently, so the behavior of test should depend only on code of target object. To reach that goal the object dependencies should be replaced to stubs, that are doing nothing or just enough for test to pass. The mocking framework is the thing that simplifies generation of such stubs.

Also, mock-objects could come in handy in other test types, when there is need to check interaction with modules that are not written yet, or with system that works too slow to be used in automated testing.

There are different types of mock-objects:

  • stub - dumb objects.They don't contain any logic, their methods and properties return default values. Such objects are used for the cases when exact values are not needed or that dependency is not required for the test but should be passed into constructor of class under test and so on.
  • mock - clever stubs. They could check whether the certain method have been called and what arguments were used. Those objects are used to check if the target object interacts with its dependencies correctly.
  • fake - that is, usually, object, that has some functionality - just enough for testing.
 The first framework to be considered - Rhino Mocks.

May 5, 2013

The first post


As the header says, this is the first post in this blog. I plan to write about software development and everything around, the aim is to learn to use blog posting for self-development.
Since I want to use blog for obtaining skills in writing, I need some constraints not to throw writing away after few several postings. The constraint would be to create new blog entry at least once a week.
Today is Sunday and the next week starts tomorrow :)