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 | 6 months ago
tip
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  1. 0

    GitHub comment 82#248086826

    GitHub | 6 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 | 2 years 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

    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