Identify all occurrences of code that create or obtain the collaborator.
标识创建或获取合作者的代码的所有出现。
In your test code, create a mock object implementing the same interface as the collaborator.
在测试代码中,创建模仿对象且实现与合作者相同的接口。
For instance, you may change the method signature so that the collaborator object is passed in.
例如,可以更改方法签名,以便传入合作者对象。
Mock object: a subclass (or implementation) of the collaborator that follows the mock object pattern.
模仿对象:遵循模仿对象模式的合作者的子类(或实现)。
The Collaborator class constructor is still quite simple.
Collaborator类构造函数仍然十分简单。
Listing 6 shows the changes made to the Collaborator object.
清单6显示了对Collaborator对象所做的更改。
Listing 13 shows the most important part of the test example: the Collaborator class.
清单13显示了测试示例的最重要部分:collaborator类。
The only way of instantiating the Collaborator object is to provide two simple arguments.
实例化Collaborator对象的惟一方法是提供两个简单参数。
The second thing to notice is that, conversely, you couldn't use the jMock framework to mock the Collaborator class.
反过来,需要注意的第二点是您不能使用jMock框架来模拟 Collaborator 类。
Also suppose that the Collaborator object requires a string and a primitive int as parameters passed to the constructor.
同时假定Collaborator对象要求使用字符串和原始的int作为传递给构造函数的参数。
Instead of accepting an ICollaborator interface, it now accepts a concrete class implementation (the Collaborator class).
它现在不接受ICollaborator接口,而接受具体类实现(collaborator类)。
The second change required is to construct (at the very least) an object array holding the actual values of parameters to be passed into the Collaborator class' constructor.
必需的第二项更改是(至少)构造一个保存传递给 Collaborator类的构造函数的参数实际值的对象数组。
The second change required is to construct (at the very least) an object array holding the actual values of parameters to be passed into the Collaborator class' constructor.
必需的第二项更改是(至少)构造一个保存传递给 Collaborator类的构造函数的参数实际值的对象数组。
应用推荐