joke / spock-mockable

Mock the un-mockable
Apache License 2.0
28 stars 2 forks source link

StaticMockHandler not found when calling a static method on a spied object #382

Open mimkorn opened 1 year ago

mimkorn commented 1 year ago

I get

Caused by: java.lang.NoClassDefFoundError: io/github/joke/spockmockable/agent/StaticMockHandler
    at java.base/java.time.LocalDateTime.of(LocalDateTime.java:374)
    at java.base/java.time.LocalDateTime.<clinit>(LocalDateTime.java:144)
    at jdk.zipfs/jdk.nio.zipfs.ZipUtils.dosToJavaTime(ZipUtils.java:118)
    ....

when running this minimal test:

import spock.lang.Specification
import java.time.LocalDateTime

class ExperimentSpecTest extends Specification {

    def "test"() {
        def of = LocalDateTime.of(2023, 1, 2, 3, 4)
        def spyTime = Spy(LocalDateTime)
    }
}

Using Spock 2.1, spock-mockable 2.3.2

The order of calls does not matter.

The whole test execution crashes, so no tests run at all with that failure.