修复它之前,首先编写一个测试。
所以下一步就是为这个方法编写一个测试。
我们应该编写一个测试应用程序来处理这些中断。
A test application should be written to handle these interrupts.
首先用一条未监护的日志语句编写一个测试案例。
编写一个测试。
编写一个测试。
作为响应,我可以编写一个测试,它将达到100%的行覆盖率。
In response, I can write one test, which achieves 100 percent line coverage.
这个模式非常简单:就像行为没有实现方面那样为系统编写一个测试。
This pattern is very simple: write a test against your system as you would if the behavior were not implemented with aspects.
当每个类都有了至少一个测试,再为每一个方法编写一个测试。
Once every class has at least one test, write one test for every method.
当每个程序包都有了至少一个测试,再为每一个类编写一个测试。
Once every package has at least one test, write one test for every class.
为用作示例,我将编写一个测试,模拟用户选择0行处组合框中的第二个元素。
As an example, I'll write a test that simulates a user selecting the second element in the combo box at row 0. The actions for the test to perform are.
为Account 的withdraw()方法编写一个测试。
Write a test for the withdraw() method on Account. Your test should now look like Listing 6
接下来,您想要编写一个测试,不仅要验证输出得到了显示,还要验证输出是正确的。
Next, you want to write a test that verifies not only that the output is present, but that it's correct. There are two ways you can do this
每次编写新代码时,添加一个测试,每次修复一个bug时,编写一个测试。
Every time you write new code, add a test, and every time you fix a bug, write a test.
现在,可以编写一个测试脚本并与测试应用程序一起运行,以检验测试中的组件。
A test script can now be written and run with this test application to exercise the component under test.
在编写一个测试来表达您试图实现的结果之后,您可以一直调试直到测试结果是良性的。
After writing a test that expresses the result you're trying to achieve, you then debug until the test is positive.
您首先想到的可能是:到重构的时间了,但这样做将打破第一个重构规则,即将编写一个测试用例。
Your first thought could be that it's time to refactor, but doing so would break the first rule of refactoring, which is to write a test case.
所以,换句话说,要使用我的策略,只需编写一个测试案例类,然后总是将其部署到客户机和服务器就可以了。
So, in other words, to use my strategy, simply write one test case class, and then always deploy to both the client and the server.
在Wikipedia上查找到前几个完全数之后,我可以编写一个测试,它检查实际上是否可以找到完全数。
After checking with Wikipedia to find the first few perfect Numbers, I can write a test that verifies that I can in fact find perfect Numbers.
这种“编写一个测试,编写足够的代码来使测试通过,重新进行测试”方法是您每天都在经历的XP开发流程。
This "write a test, write just enough code to get it to pass, rerun the test" approach is the xp development flow that you should experience every day.
这样的情景您也许并不陌生:您在编写一个测试程序,程序需要暂停一段时间,于是调用Thread .sleep 。
This story is probably familiar: you're writing a test program and you need to pause for some amount of time, so you call Thread.sleep .
从功能性观点考虑,您或许希望编写一个测试:填入表单值,单击Submit按钮,然后验证表单是否显示定义。
From a functional standpoint, you'd probably want to write a test to fill in the form value, click the Submit button, and then verify the presence of the definition under the form.
编写一个测试清理方面,自动在每次测试后像在例子中那样重新设置方面从概念上来说是简单的,但是其细节超出了本文的范围。
Writing a test-cleanup aspect to automatically reset aspects like the one in the example after each test is conceptually simple, but the details are beyond the scope of this article.
当每个方法都有了至少一个测试,使用一个代码覆盖率工具如cobertura为每个分支编写一个测试,直到每一行代码都能够被测试。
Once every method has at least one test, use a code coverage tool, such as Cobertura, to write one test for every branch until each line of code is tested.
产品发布以后,如果发现了一个缺陷,我们会编写一个测试,并且在所有的版本中进行验证,看看这个缺陷是不是已经在某个版本里面被修复了。
When a bug is found after a product has been released, a test is written and verified against all channel builds to see if the bug has already been fixed in one of the channels.
同样,一般情况下要为每个控制器编写一个功能测试。
Again, generally you write one functional test for each controller you have.
下一步是编写一个简单的测试脚本,这个脚本将一个条目添加到队列中。
The next step is to write a simple test script that adds an entry to the queue.
对于那些希望编写一个新的测试框架的人员而言,门槛降低了。
For those who want to write a new test framework, the barrier for entry is lower.
应该遵循下面这条很好的原则:即只要您认为有必要对代码中的某个行为加注,就编写一个单元测试。
A good guideline to follow is to write a unit test whenever you feel the need to comment some behavior in the code.
自动化测试意味着编写一个软件来测试其它软件。
Automated testing means that you write software to test other software.
应用推荐