Closed GoogleCodeExporter closed 9 years ago
FYI I can get around this by using the metaClass on MyService to mock the two()
method in my one test and then null out the metaClass in my tearDown() method.
Obviously, that's less than ideal.
Original comment by matthew....@gmail.com
on 5 Nov 2009 at 7:41
I tried the following script and it passed:
import org.gmock.GMockTestCase
@Grab(group = 'org.gmock', module = 'gmock', version = '0.8.0')
class Test extends GMockTestCase {
def myService
void setUp() {
def log = 'log'
MyService.class.metaClass.getLog << { -> log }
myService = new MyService()
}
void testPartialMockingWithAlteredMetaClass() {
mock(myService).two()
play {
myService.one()
}
}
}
class MyService {
def one() {
assert log == 'log'
two()
}
def two() {
throw new RuntimeException('The original method should not be called')
}
}
Original comment by JohnnyJianHY
on 6 Nov 2009 at 1:14
I cannot reproduce this issue even in the environment of Grails 1.2.1
Original comment by JohnnyJianHY
on 25 Feb 2010 at 9:21
Original issue reported on code.google.com by
matthew....@gmail.com
on 5 Nov 2009 at 6:52