keeganwitt / gmock

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

Allow users provide name for mocks #62

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
As we are going to provide default behavior for toString(), we'd better
allow users provide name for mocks. For example:

def mock = mock(Date, name: "date mock")
play {
  assertEquals "date mock", mock.toString()
}

And the default name would be "Mock for (the class name)".

Original issue reported on code.google.com by JohnnyJianHY on 7 Feb 2009 at 12:43

GoogleCodeExporter commented 9 years ago
That's not a bad idea. The syntax should probably follow the constructor and
invokeConstructor:
def mock = mock(Date, name("date mock"))

Original comment by julien.g...@gmail.com on 7 Feb 2009 at 12:48

GoogleCodeExporter commented 9 years ago
That will make the signatures of mock() very complicated.

Original comment by JohnnyJianHY on 7 Feb 2009 at 12:59

GoogleCodeExporter commented 9 years ago
I agree it's getting more complicated... I think we should provide an Object...
signature and find out what has been provided by the user.

Original comment by julien.g...@gmail.com on 7 Feb 2009 at 3:04

GoogleCodeExporter commented 9 years ago
That may be not easy to implement, as it is hard to cover all cases and handle 
all
errors.

Original comment by JohnnyJianHY on 7 Feb 2009 at 4:35

GoogleCodeExporter commented 9 years ago
Seems it is not that difficult, I am going to have a try.

Original comment by JohnnyJianHY on 11 Feb 2009 at 9:58

GoogleCodeExporter commented 9 years ago

Original comment by JohnnyJianHY on 11 Feb 2009 at 11:49