These are chat archives for spockframework/spock

Dec 2017
Casey Link
Dec 07 2017 06:57
Where do I put interaction asserts when using given/expect/where ?
Chi Cuong Le
Dec 07 2017 08:15
What do you mean with interaction assert?
All assertions in expect block ?
André Kirchner
Dec 07 2017 09:14
Good morning everyone.
I'm trying to test a method that contains the instantiation of an external Class (new ExternalClass()) --> I'm trying to mock/stub this external Class, but I'm not sure how to do it. My usual ExternalClass mocky = Mock(ExternalClass) doesn't seem to work, because the instance is created on the fly in the tested method.
Do you guys have any idea & can anyone please help a newb
Thanks in advance
Leonard Brünings
Dec 07 2017 09:24
@SharkeyO mocking of constructor calls is only supported if the class in question is a groovy class, if you are testing Java code then it is not possible with spock.
Chi Cuong Le
Dec 07 2017 09:28
@SharkeyO Other solution, define your external instance as a dependency of your under tested class. That means it will not be created on the fly but at beginning initial phase. Then you can mock this class
André Kirchner
Dec 07 2017 09:36
Thanks, it's truely a design issue for the method