Forgus / spock

Automatically exported from code.google.com/p/spock
0 stars 0 forks source link

Improve spy error message when constructor args dont match #277

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
1. Create some spy like: Spy(Foo, constructorArgs: 'foo')
2. If Foo class does not have any constructor then:

java.lang.ClassCastException
    at java.lang.Class.cast(Class.java:2990)
    at org.spockframework.mock.runtime.MockConfiguration.getOption(MockConfiguration.java:92)
    at org.spockframework.mock.runtime.MockConfiguration.<init>(MockConfiguration.java:46)
    at org.spockframework.lang.SpecInternals.createMock(SpecInternals.java:47)
    at org.spockframework.lang.SpecInternals.createMockImpl(SpecInternals.java:282)
    at org.spockframework.lang.SpecInternals.SpyImpl(SpecInternals.java:171)
    at org.gradle.execution.ExcludedTaskFilteringBuildConfigurationActionTest.$spock_initializeFields(ExcludedTaskFilteringBuildConfigurationActionTest.groovy:30)

Original issue reported on code.google.com by szcze...@gmail.com on 23 Oct 2012 at 9:03

GoogleCodeExporter commented 8 years ago
The problem here is not the actual ctor args, but that you are supposed to pass 
a List to "constructorArgs:". (I'd expect a better message otherwise.) That 
said, maybe we shouldn't cast to List but use Groovy iteration semantics 
instead.

Original comment by pnied...@gmail.com on 23 Oct 2012 at 9:25