Pergunta

I want to use return vale of a expectation to add to one more expection. I have a m_accountProcessor object which has interface createAccount to create a new account and returns a Account object. I want to save this object and add it to one more expectation for encode function call. How can I save the value?

       m_context.checking(new Expectations() {{

        one(m_accountProcessor).createAccount(CUSTOMER_DETAILS);
        //How can I save the return value of createAccount's Account object
         one(m_accountProcessor).encode(/*AccountObject*/);
       }}
Foi útil?

Solução

Don't forget, you're not calling the real account processor, you're imitating its behaviour. Create an account object in the test, you can return the using the

will(returnValue(account));

clause, and expect to have it passed back to the account processor for encoding.

Bonus questions, why are you getting an object out of the account processor and then passing it back for encoding?

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top