Coding this way does not make fixing bugs any easier. Simple bugs (like
this one) require simple test cases; complex bugs will require complex
test cases.
In a testing−centric environment, it may seem like it takes longer to fix a bug, since you need to articulate in code exactly what the bug is (to write the test case), then fix the bug itself.
Then if the test case doesn't pass right away, you need to figure out whether the fix was wrong, or whether the test case itself has a bug in it.
[pope译]
这种编码方式并不能更简单的修复bug。简单的bug(想这个)需要简单的测试用例;复杂的bug会需要复杂的测试用例。
在测试中,看起来更像用较长时间修复bug,你需要明确{articulate}代码中这个bug的什么(并写到测试用例中),然后修复这个bug。
那么如果测试用例并没有使用正确的方式测试通过,你需要想想{}这个修复是否是错误的,或者这个测试用例本身有bug
However, in the long run, this back−and−forth between test code and code tested pays for itself, because it makes it more likely that bugs are fixed correctly the first time. Also, since you can easily re−run all the test cases along with your new one, you are much less likely to break old code when fixing new code. Today's unit test is tomorrow's regression test
[pope译]
无论如何,在长时间过去后,重拾之前的测试代码和被测试的代码,这个过程使得它看起来更像是bug们在第一时间被准确的修复了。并且,在你的添加新内容后,你就可以简单的运行全部测试用例了,这样你可以在添加新代码时更少的打乱旧代码了。今天的单元测试就是明天的防止退化的测试{regression test}
In a testing−centric environment, it may seem like it takes longer to fix a bug, since you need to articulate in code exactly what the bug is (to write the test case), then fix the bug itself.
Then if the test case doesn't pass right away, you need to figure out whether the fix was wrong, or whether the test case itself has a bug in it.
[pope译]
这种编码方式并不能更简单的修复bug。简单的bug(想这个)需要简单的测试用例;复杂的bug会需要复杂的测试用例。
在测试中,看起来更像用较长时间修复bug,你需要明确{articulate}代码中这个bug的什么(并写到测试用例中),然后修复这个bug。
那么如果测试用例并没有使用正确的方式测试通过,你需要想想{}这个修复是否是错误的,或者这个测试用例本身有bug
However, in the long run, this back−and−forth between test code and code tested pays for itself, because it makes it more likely that bugs are fixed correctly the first time. Also, since you can easily re−run all the test cases along with your new one, you are much less likely to break old code when fixing new code. Today's unit test is tomorrow's regression test
[pope译]
无论如何,在长时间过去后,重拾之前的测试代码和被测试的代码,这个过程使得它看起来更像是bug们在第一时间被准确的修复了。并且,在你的添加新内容后,你就可以简单的运行全部测试用例了,这样你可以在添加新代码时更少的打乱旧代码了。今天的单元测试就是明天的防止退化的测试{regression test}
没有评论:
发表评论