Skip to content

Commit

Permalink
fix for GRAILS-10720 "Cannot create mock for class" - Horrible, horri…
Browse files Browse the repository at this point in the history
…ble hack, but not choice due to https://code.google.com/p/spock/issues/detail?id=335
  • Loading branch information
graemerocher committed Nov 12, 2013
1 parent 534b0f3 commit 6b02ced
Showing 1 changed file with 16 additions and 0 deletions.
Expand Up @@ -27,6 +27,8 @@ import org.junit.runner.Request
import org.junit.internal.requests.FilterRequest
import org.junit.runner.manipulation.Filter
import org.junit.runner.Description
import org.objenesis.ObjenesisHelper
import org.objenesis.ObjenesisBase

@CompileStatic
class GrailsSpecTestType extends GrailsTestTypeSupport {
Expand All @@ -36,6 +38,20 @@ class GrailsSpecTestType extends GrailsTestTypeSupport {
private int featureCount = 0
protected GrailsTestMode mode

static {
try {
final objStdField = ObjenesisHelper.getDeclaredField("OBJENESIS_STD")
objStdField.accessible = true
final objStd = objStdField.get(ObjenesisHelper)
final cacheField = ObjenesisBase.getDeclaredField("cache")
cacheField.accessible = true
cacheField.set(objStd, null)
} catch (Throwable e) {
// ignore, failed to patch
}

}

GrailsSpecTestType(String name, String relativeSourcePath) {
super(name, relativeSourcePath)
}
Expand Down

0 comments on commit 6b02ced

Please sign in to comment.