Jmockit 期望错误
我有单元测试用例,我满怀期望地使用 JMockit。 现在,当我单独运行测试用例时,测试用例通过了。但是当我一起运行所有测试用例时,我收到:
expected exactly 1 time, already invoked...
错误。我感觉以前的测试用例在jmock中设置的一些配置或状态还没有清除。
有人经历过类似的事情吗?
谢谢
I have unit test case where I am using JMockit with expectations.
Now when I run the test case alone, the test case passes. But when I run all test cases collectively, I get the:
expected exactly 1 time, already invoked...
error. I feel that some configuration or states set in jmock by previous test cases has not cleared.
Has anyone experienced something similar?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在我看来,好像您已经在模拟类上定义了允许的方法调用次数。你有类似的东西吗:
?
如果是这种情况,您需要使用 JUnit < 来拆除模拟实例code>@After 习惯用法,您将
tearDownMocks()
以重置每个测试用例中使用的模拟实例。It sounds to me as if you have defined the allowed number of invocations of a method on a mocked class. Do you have something resembling:
?
If this is the case, you need to tear down the mock instance using the JUnit
@After
idiom, in which you'll totearDownMocks()
in order to reset the mock instances used in each test case.