Ste*_*ose 4 php phpunit unit-testing design-patterns
这个问题与PHPUnit有关,虽然它应该是一个全局的xUnit设计问题.
我正在为一堂课写一个单元测试用例Image
.
这个类的方法之一是setBackgroundColor()
.
我需要为此方法测试4种不同的行为,
array(255,255,255)
array('red' => 255, 'green' => 255, 'blue' => 255)
(这是GD功能的输出格式imagecolorsforindex()
)IMG_COLOR_TRANSPARENT
目前,我已将所有这些包含在我的测试用例中的一个测试中testSetBackgroundColor()
,但是我感觉这应该是4个单独的测试,因为测试变得很长并且做了很多.
我的问题是,我该怎么办?我是否将所有这些封装到Image测试用例的1个测试中,或者将上面的内容拆分为单独的测试,例如,
testSetBackgroundColorErrors
testSetBackgroundColorShorthandRGB
testSetBackgroundColorRGB
testSetBackgroundColorTransparent
我在这里提出了有问题的测试http://pastebin.com/f561fc1ab.
谢谢