Thanks Peter, Kostis!
My method renaming example was a little too simplistic, and is indeed covered by an eclipse refactoring.
But it's easy to bump into a real world refactoring that isn't (a recent one for me was refactoring two methods: recordOperationStartTime() and recordOperationEndTime() to a single method: recordOperationDuration(long duration))
getting those 'inferencing_problems' indicated as underlined text in Eclipse is far from ideal, as you have to proactively remember to look for it in the suitable unit test file(s). Of course you should run your unit test after each change, but still it's a an order of magnitude less tighten to your changes.
Adding @TypeChecked I was able to get eclipse to mark the errors in the file in red as expected, but it does not appear to drive eclipse to display any of those errors in the problems view (or in the markers view). So it's hardly ideal also.
While this may be solved at some point by a groovy eclipse plugin improvement, I wasn't able to find the syntax for defining mocks to work with @TypeChecked. For example, who can I the following to pass type checking:
@TypeChecked
class MyDecoderSpec extends Specification {
TcpProtocol protocol = (TcpProtocol) Mock(TcpProtocol) { getHeaderVersion() >> 2 }
I'm getting errors like:
Groovy:[Static type checking] - Cannot find matching method com...connections.tcp.netty.MyDecoderSpec#getHeaderVersion(). Please check if the declared type is right and if the
method exists.
Why is it looking for getHeaderVersion() in the Spec? I've also tried relocating the mock definition to other blocks but failed to make it work.
Thanks
Gilad