我们不想对每一个类测试这个新行为。
You wouldn't want to test every class for this new behavior.
第三类测试是覆盖测试。
清单7中相应的scitter类测试也相当简单。
And the corresponding Scitter class test in Listing 7 is pretty simple too.
这两个名称一语中的地道出了施行这两类测试的原因。
These names get to the heart of the reason behind the two kinds of tests.
在美国马里兰州艾奇伍德的一套特殊装置中,美国陆军志愿者接受掩埋、酸和沙尘等类测试。
U.S. Army volunteers took pot, acid and angel dust at a facility in Edgewood, Md.
然而,当我们运行这个测试类时,我们没有得到所期望的输出。
However, when we run this test, we do not get the outcome we expect.
添加如列表6所示的代码到这个测试类中。
将此代码粘帖到您的测试类,并保存。
首先编写单元测试,然后再编写要测试的类代码。
为了保持代码简单,我把类和测试代码放在一个文件中。
To keep the code simple, I put the class and the test code in one file.
为了弄清除如何使用它,我们需要写一个测试类。
您现在已经拥有了可用于执行的测试类。
您也可以用这个类来运行测试包。
第一个选择是将此测试类转移到集成目录中。
The first option is to move this test class into the integration directory.
你每次保存这些源文件时,便调用测试类的解析。
Each time you save the source file, you invoke a parsing of the test class.
下面是我们的简单示例所生成的测试用例类。
Here is the generated test case class for our simple example.
可以很直观地写出对堆栈类的单元测试。
清单3显示了字典应用程序的开始测试类。
Listing 3 shows the dictionary application's beginning test class.
现在,想像一下对发出开销较高的SOAP调用的类进行单元测试。
Now imagine trying to unit test a class that makes an expensive SOAP call.
这个测试类的名称可以更改。
现在需要运行编组程序测试类。
类图交付单元测试所需的构架信息。
Class diagrams deliver the structural information unit testers need.
在uml模型中,创建一个测试包和类。
图2进一步描述了测试类的生命周期。
The lifecycle of a test class is further illustrated in Figure 2.
要运行测试用例类,需要启动服务器。
测试类的名称也可以修改。
此时,重新运行前面描述的测试类会产生正确的结果。
At this point, re-running the test described previously results in the correct result.
运行这个测试类产生的预期结果
对于每个案例来说,您都需要从TestCase扩展您的测试类。
For each test case. basically you need to extend your test class from TestCase.
为特定的函数或类生成测试。
应用推荐