keeganwitt / gmock

Automatically exported from code.google.com/p/gmock
6 stars 2 forks source link

Support for multiple method calls mocking with different result #126

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
E.g. if I want to mock readLine() method in BufferedReader, I can't
do 

BufferedReader mockInput = mock(BufferedReader)
mockInput.readLine().returns('1234').readLine().returns('def').

So I can then 

play {
 assertEquals '1234', mockInput.readLine()
 assertEquals 'def', mockInput.readLine()
}

Original issue reported on code.google.com by gousei...@gmail.com on 26 Mar 2012 at 9:14

GoogleCodeExporter commented 8 years ago
Actually, you can:

mockInput.readLine().returns('1234').returns('def')

Original comment by JohnnyJianHY on 26 Mar 2012 at 9:17

GoogleCodeExporter commented 8 years ago
Thanks a lot, it worked. I was looking how to do that in the documentation, but 
didn't found. 

Original comment by gousei...@gmail.com on 26 Mar 2012 at 9:24

GoogleCodeExporter commented 8 years ago

Original comment by JohnnyJianHY on 26 Mar 2012 at 10:24