pchudzik / springmock

alternative spring mocking infrastructure
https://blog.pchudzik.com/201707/springmock-v1/
MIT License
22 stars 4 forks source link

Null Pointer exception when names don't match up #15

Closed M21B8 closed 7 years ago

M21B8 commented 7 years ago

If the mocks variable name doesn't match the bean name, it can't find the bean to mock, and it falls over with a NPE. I can get round it by making the names match, but seems a bit inflexible.

for example: @AutowiredSpy ProjectionService spy

java.lang.NullPointerException
    at org.spockframework.mock.MockUtil.asMock(MockUtil.java:54)
    at org.spockframework.mock.MockUtil.attachMock(MockUtil.java:68)
    at com.pchudzik.springmock.spock.spring.MockAttachingTestExecutionListener.beforeTestMethod(MockAttachingTestExecutionListener.java:59)
pchudzik commented 7 years ago

should work better in latest snapshot. 1.1.1-SNAPSHOT. Will release it soon.

pchudzik commented 7 years ago

It is released as 1.1.2 http://search.maven.org/#artifactdetails%7Ccom.pchudzik.springmock%7Cspringmock-spock%7C1.1.2%7C http://search.maven.org/#artifactdetails%7Ccom.pchudzik.springmock%7Cspringmock-mockito%7C1.1.2%7C