Size: 5056
Comment:
|
Size: 6756
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 40: | Line 40: |
* '''1.''' The existing known values don't change (they're all still reasonable values to test), but you need to add a few more in the 4000 range. Here I've included 4000 (the shortest), 4500 (the second shortest), 4888 (the longest), and 4999 (the largest). * '''1.''' 原来的已知值没有改变(它们仍然是合理的测试值)但你需要添加几个大于 4000 的值。 这里我添加了 4000 (--(罗马数字表示)--最短的一个), 4500 (次短的一个), 4888 (最长的一个)和 4999 (值最大的一个)。 * '''2.''' The definition of “large input” has changed. This test used to call toRoman with 4000 and expect an error; now that 4000-4999 are good values, you need to bump this up to 5000. * '''2.''' “最大输入”的 <!> 概念^定义^改变了。 以前是以 4000 调用 toRoman 并期待一个错误;而现在 4000-4999 成为了有效输入,需要将这个 <!> 测试的对象^“最大输入”^提升至 5000。 * '''3.''' The definition of “too many repeated numerals” has also changed. This test used to call fromRoman with 'MMMM' and expect an error; now that MMMM is considered a valid Roman numeral, you need to bump this up to 'MMMMM'. * '''3.''' “过多字符重复” 的 <!> 概念^定义^也改变了。 这个测试以前是以 'MMMM' 调用 <!> ^fromRoman ^并期待一个错误;而现在 MMMM 被认为是一个有效的罗马数字表示,需要将这个 <!> 测试的对象提升至^“过多字符重复”改为^ 'MMMMM'。 * '''4.''' The sanity check and case checks loop through every number in the range, from 1 to 3999. Since the range has now expanded, these for loops need to be updated as well to go up to 4999. * '''4.''' <!> 回旋^完备^测试和大小写测试 <!> ^原来^在 1 到 3999 范围内循环。--(由于)--现在范围扩展了,这个 for 循环 <!> ^也^需要将范围提升至 4999。 |
* 1 The existing known values don't change (they're all still reasonable values to test), but you need to add a few more in the 4000 range. Here I've included 4000 (the shortest), 4500 (the second shortest), 4888 (the longest), and 4999 (the largest). * 1 原来的已知值没有改变(它们仍然是合理的测试值)但你需要添加几个大于 4000 的值。 这里我添加了 4000 (--(罗马数字表示)--最短的一个), 4500 (次短的一个), 4888 (最长的一个)和 4999 (值最大的一个)。 * 2 The definition of “large input” has changed. This test used to call toRoman with 4000 and expect an error; now that 4000-4999 are good values, you need to bump this up to 5000. * 2 “最大输入”的 <!> 概念^定义^改变了。 以前是以 4000 调用 toRoman 并期待一个错误;而现在 4000-4999 成为了有效输入,需要将这个 <!> 测试的对象^“最大输入”^提升至 5000。 * 3 The definition of “too many repeated numerals” has also changed. This test used to call fromRoman with 'MMMM' and expect an error; now that MMMM is considered a valid Roman numeral, you need to bump this up to 'MMMMM'. * 3 “过多字符重复” 的 <!> 概念^定义^也改变了。 这个测试以前是以 'MMMM' 调用 <!> ^fromRoman ^并期待一个错误;而现在 MMMM 被认为是一个有效的罗马数字表示,需要将这个 <!> 测试的对象提升至^“过多字符重复”改为^ 'MMMMM'。 * 4 The sanity check and case checks loop through every number in the range, from 1 to 3999. Since the range has now expanded, these for loops need to be updated as well to go up to 4999. * 4 <!> 回旋^完备^测试和大小写测试 <!> ^原来^在 1 到 3999 范围内循环。--(由于)--现在范围扩展了,这个 for 循环 <!> ^也^需要将范围提升至 4999。 |
Line 50: | Line 50: |
* Now your test cases are up to date with the new requirements, but your code is not, so you expect several of the test cases to fail. * 现在你的 <!> 独立测试已经根据要求完成了更新^测试用例和新需求保持一致了^, 但是你的程序--(代码)--还没有,因此几个 <!> 独立测试^测试用例^的失败是意料之中的事。 * Example 15.7. Output of romantest71.py against roman71.py * 例 15.7. <!> 以^用^ romantest71.py 测试 roman71.py 的 <!> 输出^结果^ ---- '''对输出的说明 ''' * 1 Our case checks now fail because they loop from 1 to 4999, but toRoman only accepts numbers from 1 to 3999, so it will fail as soon the test case hits 4000. * 2 The fromRoman known values test will fail as soon as it hits 'MMMM', because fromRoman still thinks this is an invalid Roman numeral. * 3 The toRoman known values test will fail as soon as it hits 4000, because toRoman still thinks this is out of range. * 4 The sanity check will also fail as soon as it hits 4000, because toRoman still thinks this is out of range. * 1 我们的 <!> 独立测试^大小写检查^失败是 <!> 因^因为^循环范围是 1 到 4999 --(而导致)--, <!> 但是^而^ toRoman 只接受 1 到 3999的 <!> 范围^之间的数^,因此 <!> 测试到达^循环到^ 4000 就会失败。 * 2 fromRoman 的已知值测试在遇到 'MMMM' 就会失败,因为 fromRoman 还认为这是一个无效的罗马数字表示。 * 3 toRoman 的已知值测试在遇到 4000 就会失败,因为 toRoman 仍旧认为这 <!> 越^超^出了有效值范围。 * 4 <!> 回旋 ^完备^测试在遇到 4000 <!> 便^也会^失败,因为 toRoman 还认为这 <!> 越^超^出了有效值范围。 ---- |
2006-03-27 校对记要
校对文件: roman.xml
第15章第2节
标题
- Handling changing requirements
应对
要求需求变化
第一段
- Despite your best efforts to pin your customers to the ground and extract exact requirements from them on pain of horrible nasty things involving scissors and hot wax, requirements will change. Most customers don't know what they want until they see it, and even if they do, they aren't that good at articulating what they want precisely enough to be useful. And even if they do, they'll want more in the next release anyway. So be prepared to update your test cases as requirements change.
尽管你竭尽努力地分析你的客户需求,并点灯熬油地提炼出
相应精确的
要需求,但
要求是需求还是会变化的。 大部分客户在看到产品前不知道他们
要想要什么。即便知道,也不
能很好地善于精确表述出他们的有效需求。即便能表述出来,他们
下一次在下一个版本一定
要会要求更多的功能。 因此你需要
让你的独立测试做好更新准备做好更新测试用例的准备以应对
要求需求的改变。
第2段
- Suppose, for instance, that you wanted to expand the range of the Roman numeral conversion functions. Remember the rule that said that no character could be repeated more than three times? Well, the Romans were willing to make an exception to that rule by having 4 M characters in a row to represent 4000. If you make this change, you'll be able to expand the range of convertible numbers from 1..3999 to 1..4999. But first, you need to make some changes to the test cases.
假设你想要扩展罗马数字转换
函数的范围。
记住 这条原则 :没有哪个字符可以重复三遍以上 还记得“没有哪个字符可以重复三遍以上”这条规则 吗?
啊哈!罗马数字可以连续出现 4 次M 字符来表示 4000 便是一个例外呃, 现在罗马人希望给这条规则来个例外,用连续出现 4 个M 字符来表示 4000。 如果
你做出这个改变这样改了,你
则就可以把转换范围从 1..3999 扩展到 1..4999。 但首先,你先要对
独立测试测试用例进行修改。
Example 15.6
- Example 15.6. Modifying test cases for new requirements (romantest71.py)
例 15.6.
修改独立测试以适应新要求 为新需求修改测试用例(romantest71.py)
- This file is available in py/roman/stage7/ in the examples directory.
这个文件可以
从 在例子目录下的 py/roman/stage7/ 的 examples 目录中
获得 找到 。
Example 15.6 的说明
- 1 The existing known values don't change (they're all still reasonable values to test), but you need to add a few more in the 4000 range. Here I've included 4000 (the shortest), 4500 (the second shortest), 4888 (the longest), and 4999 (the largest).
1 原来的已知值没有改变(它们仍然是合理的测试值)但你需要添加几个大于 4000 的值。 这里我添加了 4000 (罗马数字表示最短的一个), 4500 (次短的一个), 4888 (最长的一个)和 4999 (值最大的一个)。
- 2 The definition of “large input” has changed. This test used to call toRoman with 4000 and expect an error; now that 4000-4999 are good values, you need to bump this up to 5000.
2 “最大输入”的
概念定义改变了。 以前是以 4000 调用 toRoman 并期待一个错误;而现在 4000-4999 成为了有效输入,需要将这个
测试的对象“最大输入”提升至 5000。
- 3 The definition of “too many repeated numerals” has also changed. This test used to call fromRoman with 'MMMM' and expect an error; now that MMMM is considered a valid Roman numeral, you need to bump this up to 'MMMMM'.
3 “过多字符重复” 的
概念定义也改变了。 这个测试以前是以 'MMMM' 调用
fromRoman 并期待一个错误;而现在 MMMM 被认为是一个有效的罗马数字表示,需要将这个
测试的对象提升至“过多字符重复”改为 'MMMMM'。
- 4 The sanity check and case checks loop through every number in the range, from 1 to 3999. Since the range has now expanded, these for loops need to be updated as well to go up to 4999.
4
回旋完备测试和大小写测试
原来在 1 到 3999 范围内循环。由于现在范围扩展了,这个 for 循环
也需要将范围提升至 4999。
- Now your test cases are up to date with the new requirements, but your code is not, so you expect several of the test cases to fail.
现在你的
独立测试已经根据要求完成了更新测试用例和新需求保持一致了, 但是你的程序代码还没有,因此几个
独立测试测试用例的失败是意料之中的事。
- Example 15.7. Output of romantest71.py against roman71.py
例 15.7.
以用 romantest71.py 测试 roman71.py 的
输出结果
对输出的说明
- 1 Our case checks now fail because they loop from 1 to 4999, but toRoman only accepts numbers from 1 to 3999, so it will fail as soon the test case hits 4000.
- 2 The fromRoman known values test will fail as soon as it hits 'MMMM', because fromRoman still thinks this is an invalid Roman numeral.
- 3 The toRoman known values test will fail as soon as it hits 4000, because toRoman still thinks this is out of range.
- 4 The sanity check will also fail as soon as it hits 4000, because toRoman still thinks this is out of range.
1 我们的
独立测试大小写检查失败是
因因为循环范围是 1 到 4999 而导致,
但是而 toRoman 只接受 1 到 3999的
范围之间的数,因此
测试到达循环到 4000 就会失败。
- 2 fromRoman 的已知值测试在遇到 'MMMM' 就会失败,因为 fromRoman 还认为这是一个无效的罗马数字表示。
3 toRoman 的已知值测试在遇到 4000 就会失败,因为 toRoman 仍旧认为这
越超出了有效值范围。
4
回旋 完备测试在遇到 4000
便也会失败,因为 toRoman 还认为这
越超出了有效值范围。