jtanistra / spock

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

Failing test passes because of NPE #366

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
If a mock argument produces NPE on equals(), then test passes well in IDEA, 
invocations number is not checked, object equivalence is not checked

When running from gradle, gradle is stuck with stack trace in a console

:bl:test
Unexpected exception thrown.
org.gradle.messaging.remote.internal.MessageIOException: Could not write 
message [ChannelMessage channel: org.gradle.api
.internal.tasks.testing.TestResultProcessor, payload: [MethodInvocation method: 
failure()]] to '/127.0.0.1:3636'.
        at org.gradle.messaging.remote.internal.inet.SocketConnection.dispatch(SocketConnection.java:115)
        at org.gradle.messaging.remote.internal.hub.MessageHub$ConnectionDispatch.run(MessageHub.java:279)
        at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java
:66)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.NullPointerException: Cannot invoke method hashCode() on 
null object
        at org.codehaus.groovy.runtime.NullObject.hashCode(NullObject.java:160)
        at org.codehaus.groovy.runtime.NullObject$hashCode.call(Unknown Source)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
        at org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:32)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
        at com.salespredict.test.MyObject.hashCode(MyObject.groovy:24)
        at java.util.AbstractList.hashCode(AbstractList.java:541)
        at org.spockframework.mock.runtime.MockInvocation.hashCode(MockInvocation.java:93)
        at java.util.HashMap.hash(HashMap.java:366)
        at java.util.HashMap.put(HashMap.java:496)
        at org.spockframework.util.AbstractMultiset.add(AbstractMultiset.java:40)
        at org.spockframework.util.AbstractMultiset.addAll(AbstractMultiset.java:74)
        at org.spockframework.util.HashMultiset.<init>(HashMultiset.java:18)
        at org.spockframework.mock.TooFewInvocationsError.getMessage(TooFewInvocationsError.java:46)
        at org.gradle.messaging.remote.internal.Message$ExceptionPlaceholder.<init>(Message.java:74)
        at org.gradle.messaging.remote.internal.Message$TopLevelExceptionPlaceholder.<init>(Message.java:138)
        at org.gradle.messaging.remote.internal.Message$TopLevelExceptionPlaceholder.<init>(Message.java:136)
        at org.gradle.messaging.remote.internal.Message$ExceptionReplacingObjectOutputStream.replaceObject(Message.java:
151)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1143)
        at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1377)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1173)
        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)
        at org.gradle.messaging.remote.internal.Message.send(Message.java:29)
        at org.gradle.messaging.serialize.kryo.JavaSerializer$JavaWriter.write(JavaSerializer.java:62)
        at org.gradle.messaging.remote.internal.hub.MethodInvocationSerializer$MethodInvocationWriter.writeArguments(Met

See sources attached 
What version of Spock and Groovy are you using?
spock-core:0.7-groovy-2.0
groovy-all-2.0.5

Original issue reported on code.google.com by jav...@gmail.com on 18 Jun 2014 at 8:14

Attachments: