user
09/28/2023, 1:37 PMdef sessionMock(Session) {
getConfig() >> [ [hello: 'test'] ]
}
Error
java.lang.ExceptionInInitializerError
at org.spockframework.mock.runtime.CglibMockFactory.createMock(CglibMockFactory.java:24)
at org.spockframework.mock.runtime.ProxyBasedMockFactory.create(ProxyBasedMockFactory.java:45)
at org.spockframework.mock.runtime.JavaMockFactory.createInternal(JavaMockFactory.java:58)
at org.spockframework.mock.runtime.JavaMockFactory.create(JavaMockFactory.java:38)
at org.spockframework.mock.runtime.CompositeMockFactory.create(CompositeMockFactory.java:44)
at org.spockframework.lang.SpecInternals.createMock(SpecInternals.java:50)
at org.spockframework.lang.SpecInternals.createMockImpl(SpecInternals.java:305)
at org.spockframework.lang.SpecInternals.createMockImpl(SpecInternals.java:295)
at org.spockframework.lang.SpecInternals.MockImpl(SpecInternals.java:108)
Caused by: net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InaccessibleObjectException-->Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @7549926c
at app//net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:464)Ben Sherman
09/28/2023, 2:43 PM>> should happen inside a mock constructor or under a Spock label like when: or then:Ben Sherman
09/28/2023, 2:43 PMdef session = Mock(Session) {
getConfig() >> [ ... ]
}user
09/28/2023, 6:02 PMimport nextflow.Session
import spock.lang.Specification
class HelloTest extends Specification {
def 'should test config' () {
given:
def a = 'hello'
when:
def session = Mock(Session) {
getConfig() >> [test: a]
}
def cfg = session.getConfig()
then:
cfg.test == 'hello'
}
}user
09/28/2023, 6:09 PM