Skip to content

Commit d1a2cdf

Browse files
committed
Mention Byte Buddy in the documentation additionally to cglib and increase versions
1 parent 6585549 commit d1a2cdf

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

docs/interaction_based_testing.adoc

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -538,11 +538,20 @@ is only meant for documentation purposes and doesn't carry any semantics.
538538
=== Mocking Classes
539539

540540
Besides interfaces, Spock also supports mocking of classes. Mocking classes works
541-
just like mocking interfaces; the only additional requirement is to put `cglib-nodep-2.2` or higher
542-
and `objenesis-1.2` or higher on the class path. If either of these libraries is missing from
543-
the class path, Spock will gently let you know.
541+
just like mocking interfaces; the only additional requirement is to put `byte-buddy` 1.9+ or
542+
`cglib-nodep` 3.2.0+ on the class path.
544543

545-
NOTE: Java 8 is only supported from CGLIB 3.2.0 onwards.
544+
When using for example
545+
546+
- normal ``Mock``s or ``Stub``s or
547+
- ``Spy``s that are configured with `useObjenesis: true` or
548+
- ``Spy``s that spy on a concrete instance like `Spy(myInstance)`
549+
550+
it is also necessary to put `objenesis` 3.0+ on the class path, except for classes with accessible
551+
no-arg constructor or configured `constructorArgs` unless the constructor call should not be done,
552+
for example to avoid unwanted side effects.
553+
554+
If either of these libraries is missing from the class path, Spock will gently let you know.
546555

547556
== Stubbing
548557

spock-core/src/main/java/org/spockframework/mock/runtime/MockInstantiator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static Object instantiate(Class<?> declaredType, Class<?> actualType, @Nu
3333
return GroovyRuntimeUtil.invokeConstructor(actualType, constructorArgs == null ? null : constructorArgs.toArray());
3434
} catch (Exception e) {
3535
String msg = constructorArgs == null && useObjenesis && !objenesisAvailable ?
36-
". To solve this problem, put Objenesis 1.2 or higher on the class path (recommended), or supply " +
36+
". To solve this problem, put an up-to-date version of Objenesis on the class path (recommended), or supply " +
3737
"constructor arguments (e.g. 'constructorArgs: [42]') that allow to construct an object of the mocked type." : null;
3838
throw new CannotCreateMockException(declaredType, msg, e);
3939
}

0 commit comments

Comments
 (0)