只有在编写了测试(并失败)后,您才可以编写测试中的代码。
Only after you have your tests written (and failing) do you write the code under test.
由于尚没有为系统中的相应部分构建代码,测试失败。
The test fails because you have not yet built the code for that part of your system.
可以为那些代码片段编写更多的失败测试,直到一个合理的规范开始成形。
More failing tests could be written for those pieces of code until a reasonable specification begins to take shape.
现在您有一个即将失败的测试程序,它将告诉您真正需要编写那些代码。
Now you have a failing test that tells you exactly what code to write.
如果单元测试失败,我就无法整合任何代码。
第二次测试将提供指示失败检索的状态代码。
The second test would supply a status code indicating a failed retrieval.
单元测试还给了开发人员勇气重新划分代码,因为测试失败可以立刻告诉开发人员存在错误。
Unit tests also give developers courage to refactor the code, because a test failure tells the developer immediately if something's broken.
程序员测试还给予开发者重构代码的勇气,因为测试失败会立即告诉开发者是不是有地方出了问题。
Programmer tests also give developers courage to refactor the code, because a test failure tells the developer immediately if something's broken.
注意,这个代码仅在我测试用的旧版J VM上会失败。
Note that this code breaks only with older JVMs that I tested.
标准的TDD只编写能够使一个测试失败的足够多的代码。
接下来我甚至会进一步运行测试用例,尽管我知道它们将失败,因为我没有为该类编写任务代码。
Then I would even take it a step further and run the test cases, even though I know they will fail because I haven't actually written any of the code for it.
这个过程极其重要,因为代码以后的维护者可能会破坏原来的逻辑,这时单元测试就会失败。
This process is of Paramount importance, because future maintainers of your code are bound to tamper with the original logic at some point, and the unit tests will fail the moment something breaks.
快速导航到使测试失败的代码行。
每次流程失败的时候,就是你学习如何改进代码标准和测试实践的机会,避免重大bug再次发生。
Every time the process fails you have an opportunity to learn how to improve your coding standards and testing practices so that major bugs don't happen.
修改任何代码前先编写一个会失败的简短测试。
在测试中,调用ex版本的strsafe系列函数的程序会在调用失败时把缓冲区设为NULL,并以0xfe作为填充字节,代码如下。
For this test, the Ex versions of the strsafe functions set NULL on failure and 0xfe as the fill byte.
这段代码运行的时间十分合理,但是几个测试断言都失败了。
This code runs in a respectable time, but a couple of the test assertions fail.
因此,编写足够的代码来使测试进行编译、运行但结果失败。
So, write just enough code to get the test to compile, run, and fail.
开发团队无法在一个构建之后得到一份简明显示工作和失败测试的报告,也无法对特定区域代码的测试执行进行跟踪。
There are no reports available to the team which concisely show working and failing tests after a build or track the performance of tests in particular areas of the code over time.
而且由于每个UNIX命令都返回一个指示成功或失败的状态代码,因此,您可以使用任何命令作为“条件”——而不仅仅是使用测试操作符。
And because every UNIX command returns a status code reflecting success or failure, you can use any command as a conditional — not just the test operators.
在编写代码前编写测试这种作法意味着,在测试运行并失败之前,不会做工作中真正有趣的部分。
Writing a test before the code means you don't get to do the fun part of the job until the test runs and fails.
如果所有单元测试都失败,我就可以开始编写实际代码了。
Provided that all the unit tests fail, I know that I am ready to begin writing the actual code.
移植未经测试的遗留perl或其他语言代码的确非常困难,但编写失败测试可能会帮上大忙,是一个合理的策略。
Porting legacy, untested code in Perl or any language is just plain tough, but writing failing tests could be a great help, and are a reasonable strategy.
else代码块是一个简单的逻辑分支,根据测试期望说明选取一条路经——而不是另一条路经——之后测试将失败(或通过)的原因。
Else code block is a simple logical crossroad that helps show why the test would fail or pass if one path - and not another - is taken, according to test expectations.
这个失败说,我没有用长度为零的数组测试该代码。
This failure says that I haven't tested the code using a zero-length array. That's easy enough to fix, so I can just add a quick test and move on to the next failure, shown in Listing 4.
第一是当一个小的单元测试失败时,你可以准确地知道你的代码不满足哪个条件。
The first is that when a small unit test fails, you know exactly which criteria your code doesn't meet.
除了恰好让单元测试失败的代码(编译错误也是错误的一种),不要写更多的单元测试。
You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures.
如果在要合并其结果的测试之间已重新编译成品代码,则合并结果有时会失败。
Each time you merge test results, the new set of results replaces all previously displayed merged results.
如果在要合并其结果的测试之间已重新编译成品代码,则合并结果有时会失败。
Each time you merge test results, the new set of results replaces all previously displayed merged results.
应用推荐