keeganwitt / gmock

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

Class cast exception when not matching mocked constructor #22

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
An exception is throw when trying to match a constructor.

The following test should pass:

    void testConstructorDifferentClassExpected(){
        def mockLoader1 = mock(Loader, constructor: ["1"])

        def now = new Date()
        try {
            play {
                def loader = new Loader(now)
            }
            fail("Should have throw an exception")
        } catch (AssertionFailedError e){
            def expected = "Unexpected constructor call 'new
Loader(${now.inspect()})'\n"+
                           "  'new Loader(\"1\")': expected 1, actual 0"
            assertEquals expected, e.message
        }

    }

Original issue reported on code.google.com by julien.g...@gmail.com on 30 Oct 2008 at 7:24

GoogleCodeExporter commented 9 years ago
It's a bug of Groovy 1.5.4. Update to Groovy 1.5.7, then the test will pass.

Original comment by JohnnyJianHY on 31 Oct 2008 at 4:16

GoogleCodeExporter commented 9 years ago
Then there is nothing we can do about it. I'll close it.

Original comment by julien.g...@gmail.com on 31 Oct 2008 at 7:49

GoogleCodeExporter commented 9 years ago
Why not update to Groovy 1.5.7?

Original comment by JohnnyJianHY on 31 Oct 2008 at 7:57

GoogleCodeExporter commented 9 years ago
People using 1.5.7 will see the fix. We don't have to do anything.

Original comment by julien.g...@gmail.com on 3 Nov 2008 at 7:47

GoogleCodeExporter commented 9 years ago
I remember that someone said on the groovy maillist that, it is a risk to 
compile 
the code on one version of groovy but run it on another.

Original comment by JohnnyJianHY on 3 Nov 2008 at 9:40

GoogleCodeExporter commented 9 years ago
Humm. You might be right. At don't know in which extends librairy compile in
different version could conflict.

Grails is currently using groovy 1.5.6 so it would make sense to me to upgrade 
to
that version. Alternatively we could propose gmock for different version of 
groovy -
which might be a bit heavy if different version are generally compatible.

Original comment by julien.g...@gmail.com on 3 Nov 2008 at 6:34

GoogleCodeExporter commented 9 years ago
I have an idea: instead of providing different version of gmock for different 
version of groovy, maybe we can provide a version which includes only source 
files, 
then they can be compiled with the actual version of groovy in runtime.

Original comment by JohnnyJianHY on 4 Nov 2008 at 9:02

GoogleCodeExporter commented 9 years ago
It's an interesting idea. It might be a be hard to manage on our side. For the 
moment
we should probably stick with the version 1.5.6 and see if we get some feedback 
of
incompatibility.

Original comment by julien.g...@gmail.com on 4 Nov 2008 at 7:21