0
我在写一个集成测试,它模拟来自前端的一系列操作。我设置我的期望是这样的:如何在jmock中使用状态?
context.checking(new Expectations() {{
States state = states("service");
allowing(service).getPendingTxn();
will(returnValue(null));
when(state.isNot("has-pending-txn"));
one(service).createPendingTxn();
will(returnValue(txnId));
then(state.is("has-pending-txn"));
allowing(service).getPendingTxn();
will(returnValue(transaction));
when(state.is("has-pending-txn"));
}});
被测代码然后按照该顺序进行调用。
这不适合我。它看起来像service.getPendingTxn()返回一个jMock空对象,而不是提供的值。我认为当我在期望之后写出(...)和(...)时,我会做错事,但我不确定。
有什么我在这里失踪?
是biState一个错字还是有两个状态对象? –
谢谢。在清理内部名字时输入错字。这现在对我来说很有用,我想我可能会有另一个预期,就是隐藏与之相关联的国家。 –
@KevinPeterson你能发表一个简短的回答并接受它,所以我们知道这是封闭的吗? –