keeganwitt / gmock

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

Mocking method calls doesnt work with ordered feature #109

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

Given this class

class Deploy {
       def executeDeploy() {
        checkout()
        executeMaven('clean')
        executeMaven('package')
        executeMaven('install')
        }
}

If i try to mock checkout and executeMaven methods without ordering the tests 
pass. but if i try this:

ordered {
 mock(Deploy).checkout()
 mock(Deploy).executeMaven('clean')
 mock(Deploy).executeMaven('package')
 mock(Deploy).executeMaven(install')
}

Than the tests fail...

What is the expected output? What do you see instead?
I expected the tests to pass

What version of the product are you using? On what operating system?
Gmock 0.8 on Ubuntu 

Please provide any additional information below.

Original issue reported on code.google.com by sussegad...@gmail.com on 18 Apr 2011 at 2:24

GoogleCodeExporter commented 8 years ago
You have created 4 mock objects in your test. Besides, I think you should use 
partial mock here:

def deploy = new Deploy()
def mockDeploy = mock(deploy)
ordered {
  mockDeploy.checkout()
  mockDeploy.executeMaven('clean')
  mockDeploy.executeMaven('package')
  mockDeploy.executeMaven('install')
}
play {
  deploy.executeDeploy()
}

Original comment by JohnnyJianHY on 18 Apr 2011 at 2:33

GoogleCodeExporter commented 8 years ago
BTW, there is a bug of using ordered and partial mock in the same time in gmock 
0.8.0. You should use gmock 0.8.1 instead.

Original comment by JohnnyJianHY on 18 Apr 2011 at 2:42

GoogleCodeExporter commented 8 years ago

Original comment by JohnnyJianHY on 28 Apr 2011 at 12:39