Can Spock Mock a Java constructor
Since the class under test is written in Groovy, you should be able to mock the constructor call by way of a global Groovy Mock/Stub/Spy (see Mocking Constructors in the Spock Reference Documentation). However, a better solution is to decouple the implementation of the MyConfigurator
class, in order to make it more testable. For example, you could add a second constructor and/or static method that allows to pass an instance of SolrZkClient
(or a base interface, if there is one). Then you can easily pass in a mock.