im单元测试新手,试图跟随TDD。Phpunit:测试结果相同
我我CardStackTest
,有测试次数,像这样......
public function testGetTopStackThrowsExceptionIfFirstArgumentNotInt()
public function testGetTopStackReturnsNullIfNoCardsAvailable()
public function testGetTopStackReturnsInstanceOfCardStack()
public function testGetTopStackRemovesAmountOfCardsFromStack()
public function testGetTopStackReturnsRestOfCardsIfNumberHigherThanCardsAvailable()
现在......这些都在工作,所有的罚款,并愉快地接受更好的测试方法命名提示。
我的问题是。在我看来,我已经想到了一种getBottomStack
方法。我知道它需要与我的getTopStack
方法完全相同的测试。也许我会为此增加一项额外的测试。
我的第一个想法是使像testReturnsInstanceOfCardStack
这样的私人方法,然后使公共测试点的私人。
但是我应该以相同的方式写每个测试,还是有办法干这个,也许做一些可重用的测试?