如何基于另一个案例构建新的单元测试用例?现在我复制+粘贴一个测试并扩展它。这是一个问题,因为如果我想在基本测试用例中进行更改,我有两种情况需要编辑。
例如,前两个函数调用下面是相同的:
def test_findHomography(self):
print "Find Homography"
kp1, kp2, matches = pano.findMatchesBetweenImages(self.images[0], self.images[1], 20)
h = pano.findHomography(kp1, kp2, matches)
print "Homography: "
print h
def test_getBoundingCorners(self):
print "Get Bounding Corners"
kp1, kp2, matches = pano.findMatchesBetweenImages(self.images[0], self.images[1], 20)
h = pano.findHomography(kp1, kp2, matches)
corners1 = pano.getImageCorners(self.images[0])
corners2 = pano.getImageCorners(self.images[1])
min, max = pano.getBoundingCorners(corners1, corners2, h)
print "Bounding Corners Left-Top: " + str(min)
print "Bounding Corners Right-Bottom: " + str(max)
答案 0 :(得分:0)
这个具体案例对我来说就像常见的设置。将相关测试分组到同一TestCase
下方,并将常用初始代码提取到setUp
TestCase
。不相关的测试会进入不同的TestCases
。
否则我认为Rui策略是合适的。