I'm still a pretty novice mocker :(
Posted: Thu Feb 05, 2009 4:38 am
Even though I've been using TDD for over a year at least, I still am a very poor mocker. I just can't seem to get the hang of mocking. So, I think what would help me is if I provide an example of a real world problem I have run into, and get some help doing mocks for it. So here goes...
I have an abstract class qCal_Value_Multi, and I want to test that it can contain multiple values. I do not want to have to create an actual child class just to test it. I'd like to be able to test its base functionality before getting more specific with child classes. So how would I go about this?
I already have qCal_Value, and it is well-tested. qCal_Value_Multi is an abstract class that extends qCal_Value (another abstract). Here is my (bare-bones) unit test case:
It is pretty late, but still... I can't seem to figure out where to go here... I have been cheating and just implementing sub-classes and testing those instead of mocking. Somebody please shine some light on this for me
Should I create an actual subclass of qCal_Value_Multi named MockqCal_Value_Multi and test that?
I have an abstract class qCal_Value_Multi, and I want to test that it can contain multiple values. I do not want to have to create an actual child class just to test it. I'd like to be able to test its base functionality before getting more specific with child classes. So how would I go about this?
I already have qCal_Value, and it is well-tested. qCal_Value_Multi is an abstract class that extends qCal_Value (another abstract). Here is my (bare-bones) unit test case:
Code: Select all
<?php
/**
* This is a series of tests that ensure that data is property handled in the qCal_Value family of classes
*/
class UnitTestCase_Value extends UnitTestCase {
/**
* Any "multi-value" values should be capable of containing multiple values, separated by commas
*/
public function testMultiValuesContainListSeparatedByCommas() {
}
}