Mocked instance of final class in Spock behaves differently in test and dev code
问题 In my JavaFX application I am using Spock and Groovy for testing. I have dedicated WebBrowserController for taking care of my JavafX WebView component. I wanted to test some functionalities that depend on current Location and Document of the WebView . Relevant part of WebBrowserController: public WebEngine getEngine() { return panel.getWebView().getEngine(); } This is how I create an instance of WebBrowserController for my tests. Notice the GroovyMock I used there - ordinary Mock(...) does