jMock 什么是上下文
阅读 jmock 文档我看到:
首先,我们必须导入 jMock 类,定义我们的测试装置类并创建一个代表发布者所在上下文的“Mockery”。上下文模拟与发布者协作的对象(在本例中为订阅者),并检查它们在测试期间是否正确使用。
我想知道“发布者存在的上下文”是什么意思,这是类的范围还是类似的东西?
Reading a jmock docs i see:
First we must import the jMock classes, define our test fixture class and create a "Mockery" that represents the context in which the Publisher exists. The context mocks out the objects that the Publisher collaborates with (in this case a Subscriber) and checks that they are used correctly during the test.
I like to know what mean "context in which the Publisher exists", this is a scope of the class or something like?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是过于正式的语言,它只是说
Mockery
保存了在任何给定时间测试的所有模拟对象的记录。在 99% 的情况下,每个测试用例都有一个Mockery
,因此测试用例就是上下文。如果您从 JMock 内部设计的角度思考,而不是从单元测试编写者的角度思考,那么文档该部分中使用的语言似乎更合适。
It's overly formal language, it's only saying that the
Mockery
holds the record of all of the mock objects under test at any given time. In 99% of cases, each test case has oneMockery
, and therefore the test case is the context.The language used in that part of the docs seems more appropriate if you're thinking from the point of view of how JMock is designed internally, rather than as a writer of unit tests.