我们需要创建三个模拟对象类。
一开始,模拟对象看上去令人生畏。
模拟对象用于验证预期值正在生成。
Mock objects are used to verify that the expected values are being generated.
模拟对象和模拟对象控制器。
这通过名为模拟对象的常见测试模式实现。
This is accomplished with the common testing pattern known as mock objects.
我们还提供了一些快速创建模拟对象的技术。
We will also present some techniques for creating mock objects quickly.
模拟对象现在已完成。
稍后我们将在第二个模拟对象实现中使用它们。
We will be using these later in our second mock object implementation.
创建一个模拟对象类作为具体类中的一个子类。
Create a mock object class as a subclass of the concrete class.
使用其他工具或者那些预先打包好的模拟对象。
我们将通过创建合适的模拟对象来启用此类测试。
We will enable such testing by creating a suitable mock object.
现在我们已使测试对我们的模拟对象使用两个接口。
We now have enabled the tests to use both interfaces to our mock object.
一些模拟对象可以在模拟对象的网站4上中找到。
Some of these can be found on the mock objects' Webpages. 4.
在最后一步中,模拟对象将报告它收到的检索通知。
In the last step, the Mock Object reports the Retrieval Notification it received.
在模拟对象里添加方法,使得您的测试正确地初始化。
Add methods to the mock object that allow you to initialize it properly for your tests.
构建基于classb类的模拟对象并向其提供期望。
A mock object based on a ClassB class is constructed and provided an expectation.
在这些示例中,我们将为每个模拟对象创建单独的模块。
In these examples, we create separate modules for each mock object.
在本文稍后的部分中我们将创建这两个服务的模拟对象。
We will create mock objects for these two services later in this article.
这些测试可让我们直接使用Customer模拟对象。
These tests enable us to exercise the Customer mock object directly.
模拟对象允许您对组件进行测试,而不必依赖于外部资源。
A mock object enables you to test your component without having to depend on the external resource.
在深入探讨模拟对象之前,让我们先来看一下以下两点异议。
Let's look at the first two objections before we delve into mock objects.
BPEL流程连续快速地对同一模拟对象发出多个不同的调用。
A BPEL process makes several different calls to the same mock object in rapid succession.
图5显示了我们介绍的测试规范、流程和模拟对象之间的关系。
Figure 5 shows the relationship between the test specifications, the process, and the mock objects we have described.
我为此项目创建了两个模拟对象,分别模拟GPS设备和UI。
I create two mock objects for this project to simulate the GPS device and the UI, respectively.
简化单元测试的一个流行技巧就是创建仅用于测试中的模拟对象。
A popular technique for simplifying unit tests is to create mock objects that are used just in the tests.
在开始使用模拟对象之前,您可能希望检查当前实现的业务流程。
Before we start work on the mock objects, you might like to examine the business process as it is currently implemented.
为了达到快速测试的目的,我们创建模拟对象来代替真实的对象。
A mock object is a replacement for a real object that we create for the express purpose of testing.
最后,您可以看到测试步骤正在检查模拟对象是否收到正确的数据。
Finally, you can see the test step checking that the mock object did receive the correct data.
已有的模拟对象类可以再度使用,稍做修改就可以用于未来的测试。
The mock object classes we have can be reused and enhanced for future tests with minimal effort.
我们的测试代码,特别是模拟对象,使我们能完全控制数据库结果。
Our test code, specifically the mock objects, give us total control over the database results.
应用推荐