Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fixed bug where setup hooks were not being created for test cases tha…

…t didn't overhead a setup defined by a parent (such as FunctionalTestCase). This is the cause of the breakage to the functional test build.
  • Loading branch information...
commit f2d5f367eecd03c019a51dd090022f41975326ce 1 parent adf7fab
graemerocher graemerocher authored
24 src/java/org/codehaus/groovy/grails/test/junit4/runner/GrailsTestCaseRunner.groovy
@@ -31,6 +31,7 @@ import org.codehaus.groovy.grails.test.support.GrailsTestTransactionInterceptor
31 31
32 32 import org.junit.internal.runners.statements.RunAfters
33 33 import org.junit.internal.runners.statements.RunBefores
  34 +import org.springframework.util.ReflectionUtils
34 35
35 36 class GrailsTestCaseRunner extends BlockJUnit4ClassRunner {
36 37
@@ -114,12 +115,15 @@ class GrailsTestCaseRunner extends BlockJUnit4ClassRunner {
114 115 protected Statement withBefores(FrameworkMethod method, Object target, Statement statement) {
115 116 def superResult = super.withBefores(method, target, statement)
116 117 if (superResult.is(statement)) {
117   - try {
118   - def setUp = new FrameworkMethod(testClass.javaClass.getMethod('setUp'))
119   - new RunAfters(statement, [setUp], target)
120   - } catch (NoSuchMethodException e) {
121   - superResult
122   - }
  118 + def setupMethod = ReflectionUtils.findMethod(testClass.javaClass, 'setUp')
  119 + if(setupMethod) {
  120 + setupMethod.accessible = true
  121 + def setUp = new FrameworkMethod(setupMethod)
  122 + new RunBefores(statement, [setUp], target)
  123 + }
  124 + else {
  125 + superResult
  126 + }
123 127 } else {
124 128 superResult
125 129 }
@@ -128,10 +132,12 @@ class GrailsTestCaseRunner extends BlockJUnit4ClassRunner {
128 132 protected Statement withAfters(FrameworkMethod method, Object target, Statement statement) {
129 133 def superResult = super.withAfters(method, target, statement)
130 134 if (superResult.is(statement)) {
131   - try {
132   - def tearDown = new FrameworkMethod(testClass.javaClass.getMethod('tearDown'))
  135 + def tearDownMethod = ReflectionUtils.findMethod(testClass.javaClass, 'tearDown')
  136 + if(tearDownMethod) {
  137 + tearDownMethod.accessible = true
  138 + def tearDown = new FrameworkMethod(tearDownMethod)
133 139 new RunAfters(statement, [tearDown], target)
134   - } catch (NoSuchMethodException e) {
  140 + } else {
135 141 superResult
136 142 }
137 143 } else {

0 comments on commit f2d5f36

Please sign in to comment.
Something went wrong with that request. Please try again.