Example 15.7. Output of romantest71.py against roman71.py
- code
-
fromRoman should only accept uppercase input ... ERROR ----------------1
toRoman should always return uppercase ... ERROR
fromRoman should fail with blank string ... ok
fromRoman should fail with malformed antecedents ... ok
fromRoman should fail with repeated pairs of numerals ... ok
fromRoman should fail with too many repeated numerals ... ok
fromRoman should give known result with known input ... ERROR-----------2
toRoman should give known result with known input ... ERROR-------------3
fromRoman(toRoman(n))==n for all n ... ERROR----------------------------4
toRoman should fail with non?integer input ... ok
toRoman should fail with negative input ... ok
toRoman should fail with large input ... ok
toRoman should fail with 0 input ... ok
[pope译]
我们的用例检查失败了因为他们是从1到4999的循环,但是toRoman仅仅支持从1到3999的循环,所以在它遇到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
[pope译]fromRoman在遇到'MMMM'时测试失败了,因为fromRoman仍然认为这是一个有问题的罗马数字
3.The toRoman known values test will fail as soon as it hits 4000, because toRoman still thinks this is out of range
[pope译] toRoman知道它遇到4000的值时测试失败,因为toRoman仍然认为这个超出范围了。
4.The sanity check will also fail as soon as it hits 4000, because toRoman still thinks this is out of range.
[pope译]
这个完整性{sanity}测试在撞到4000时仍然失败,以为toRoman认为这个超出范围
Now that you have test cases that fail due to the new requirements, you can think about fixing the code to bring it in line with the test cases. (One thing that takes some getting used to when you first start coding unit tests is that the code being tested is never "ahead" of the test cases. While it's behind, you still have some work to do, and as soon as it catches up to the test cases, you stop coding.)
[pope译]现在测试用例由于新的需求而失败,你可以想想如何修改这些代码向这些测试用例看齐{to bring it in line}(有件事要花些时间适应{one thing that takes some getting used to},当你首次开始单元测试,那些被测代码从未"领先"{ahead}于测试用例。当它们在后面时{behind},你仍有些工作要做,在它们赶上测试用例后,你才可以停止编码)
[popexizhi]这个就是TDD的要求吧,自己一直在转变自己的coding方式,这个应该多思考和实践,我现在遇到的新问题是,测试代码如何测试?:)我说的至少包括testcase和自动化的测试代码部分两种。
-
fromRoman should only accept uppercase input ... ERROR ----------------1
没有评论:
发表评论