Hi, I'm trying to upgrade from Groovy 2.3.7 to the shiniest version, 2.4.1, but I'm running into a problem where my unit tests are no longer functioning. What's happening, I believe is that the metaClass overrides that I'm defining in the unit test aren't actually being executed instead of the 'production' logic. I believe it's specific to the visibility of the methods I'm overriding, as they fail when 'private' but succeed when visibility is shifted to 'public'. When running unit tests I have a setup like: class MyLogic { void myMethod() { .... def dataObj = doInternalDBCall() ... } private DBObject doInternalDBCall() { .... // real DB interaction } } and a unit test class MyLogicTest { @Test void testMyMethod() { MyLogic.metaClass.doInternalDBCall = { new DBObject() } // populated with test data, instead of actually calling to a database .... // asserts, etc } } This fails to override the production logic when executing the unit test, as I had been expecting it. Is this a desired/known change? I don't want to make the internal logic public so (for me, at least) it was a nice feature that Groovy was able to override the implementation details even for private methods.
There are other approaches I can take to work around this, but I'd like to know if this is something that might be considered a bug (and thereby 'fixed' in the future), or if it's intended behavior.
Thank you for your time!