李小璐与贾乃亮滚床单:计算机英语

来源:百度文库 编辑:中科新闻网 时间:2024/04/29 06:24:04
On the flip side, container simulation—Mock Object based tests require that your action code is not tightly coupled
with the underlying J2EE container. This requires a cleaner design and cleaner delineation between your
model and the container. Typically, you can get a fairly clean design by using an Abstract Factory from your
Actions. Thus, your Actions never directly deal with J2EE; they talk to the Abstract Factory to get model objects.
The Abstract Factory may in turn talk to the J2EE services, like JNDI, to look up and interact with EJBs. Then,
for testing, you create an Abstract Factory that delivers Mock Objects for testing. This is the approach I usebecause
the advantage of using container simulation is you don’t have to deploy your code to the container to test it.
In short, the reason to use container simulation is speed. Tests that take a long time to run don’t get run as often.
TDD favors fast running tests.

在轻碰边, 容器模仿嘲笑对象基于的测试要求, 您的操作码不紧耦合
与部下的J2.EE 容器。 这要求更加干净的设计和擦净剂描述在您之间
模型和容器。 典型地, 您能得到一个相当干净的设计由使用一家抽象工厂从您
行动。 因而, 您的行动从未直接地成交与J2.EE; 他们与抽象工厂谈话得到式样对象。
抽象工厂也许与J2.EE 服务反过来谈话, 象JNDI, 查找和与EJBs 相处融洽。 然后,
为测试, 您创造提供假装对象为测试的一家抽象工厂。 这是方法I usebecause
使用容器模仿好处是您不必须部署您的代码到容器测试它。
简而言之, 原因使用容器模仿是速度。 需要久时间跑的测试不得到奔跑作为经常。
TDD 倾向快速的连续测试。