im new to unittesting and trying to follow TDD.
I my CardStackTest
, there is number of tests, like these...
public function testGetTopStackThrowsExceptionIfFirstArgumentNotInt()
public function testGetTopStackReturnsNullIfNoCardsAvailable()
public function testGetTopStackReturnsInstanceOfCardStack()
public function testGetTopStackRemovesAmountOfCardsFromStack()
public function testGetTopStackReturnsRestOfCardsIfNumberHigherThanCardsAvailable()
Now... these are all working and all is fine and gladly accept hints for better test method naming.
My question is. In my mind, i have already invisioned a getBottomStack
method. And i know it will need exactly the same testing as my getTopStack
method. Maybe i would add one extra test beyound this.
My first idea was to make private method like testReturnsInstanceOfCardStack
and then make the public test point to the private.
But should i write each test in same fashion, or is there a way to dry this up, maybe making some reusable tests?