org.spockframework.mock.CannotCreateMockException: Cannot create mock for class java.time.Instant because Java mocks cannot mock final classes. If the code under test is written in Groovy, use a Groovy mock.

GitHub | kurron | 2 months ago
  1. 0

    GitHub comment 82#248086826

    GitHub | 2 months ago | kurron
    org.spockframework.mock.CannotCreateMockException: Cannot create mock for class java.time.Instant because Java mocks cannot mock final classes. If the code under test is written in Groovy, use a Groovy mock.
  2. 0

    Correctly handle methods returning Optional

    GitHub | 1 year ago | Derbeth
    org.spockframework.mock.CannotCreateMockException: Cannot create mock for class java.util.Optional because Java mocks cannot mock final classes. If the code under test is written in Groovy, use a Groovy mock.
  3. 0

    Spock tries to mock return values from Stub() block

    GitHub | 2 years ago | chrylis
    org.spockframework.mock.CannotCreateMockException: Cannot create mock for class com.artsquare.studio.domain.digitization.BookingPromo. Mocking of non-interface types requires the CGLIB library. Please put cglib-nodep-2.2 or higher on the class path.
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Cannot create mock for class LoginService. Mocking of non-interface types requires the CGLIB library..?

    Stack Overflow | 2 years ago | shy dildo
    org.spockframework.mock.CannotCreateMockException: Cannot create mock for class com.zee.LoginService. Mocking of non-interface types requires the CGLIB library. Please put cglib-nodep-2.2 or higher on the class path.
  6. 0

    Chapter 7: testcase on page 160 doesn't work on GGTS3.6.0/Grails2.4.2

    manning.com | 6 months ago
    org.spockframework.mock.CannotCreateMockException: Cannot create mock for class com.grailsinaction.PostService. Mocking of non-interface types requires the CGLIB library. Please put cglib-nodep-2.2 or higher on the class path.

    Root Cause Analysis

    1. org.spockframework.mock.CannotCreateMockException

      Cannot create mock for class java.time.Instant because Java mocks cannot mock final classes. If the code under test is written in Groovy, use a Groovy mock.

      at org.spockframework.mock.runtime.JavaMockFactory.create()
    2. Spock Framework - Core Module
      DynamicProxyMockInterceptorAdapter.invoke
      1. org.spockframework.mock.runtime.JavaMockFactory.create(JavaMockFactory.java:41)
      2. org.spockframework.mock.runtime.CompositeMockFactory.create(CompositeMockFactory.java:44)
      3. org.spockframework.lang.SpecInternals.createMock(SpecInternals.java:45)
      4. org.spockframework.mock.EmptyOrDummyResponse.createDummy(EmptyOrDummyResponse.java:123)
      5. org.spockframework.mock.EmptyOrDummyResponse.respond(EmptyOrDummyResponse.java:92)
      6. org.spockframework.mock.runtime.MockController.handle(MockController.java:49)
      7. org.spockframework.mock.runtime.JavaMockInterceptor.intercept(JavaMockInterceptor.java:72)
      8. org.spockframework.mock.runtime.DynamicProxyMockInterceptorAdapter.invoke(DynamicProxyMockInterceptorAdapter.java:28)
      8 frames
    3. com.transparent.molde
      TemporalAcquisitionService.currentTime
      1. com.transparent.molde.example.core.TemporalAcquisitionService.currentTime(TemporalAcquisitionService.groovy:35)
      1 frame
    4. Groovy
      IndyInterface.selectMethod
      1. org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:232)
      1 frame