Refactoring friendly setters/getters.

21 views
Skip to first unread message

Daniil Moskovtsov

unread,
Nov 5, 2013, 4:51:43 AM11/5/13
to mock...@googlegroups.com
Hey guys. 

How can I have this code to be refactoring friendly? 
  
assertThat(model, received().setter('someSetter').arg(newValue).once());

I've managed to do that with functions by using expect, but I stuck with getters/setters.
Thanks!

Hob Spillane

unread,
Nov 5, 2013, 10:36:07 AM11/5/13
to mock...@googlegroups.com
It's been a while, but I think what you're looking for is:

expect(model.someSetter(arg(newValue))).once();

That way the compiler is picking up any changes to your method names.


--
You received this message because you are subscribed to the Google Groups "Mockolate" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mockolate+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Daniil Moskovtsov

unread,
Nov 6, 2013, 6:33:03 AM11/6/13
to mock...@googlegroups.com
Thank for the answer. 
Unfortunately the code you've provided is not working for me as "someSetter" is setter and not function so you can not wrap it with brackets. 

вторник, 5 ноября 2013 г., 16:36:07 UTC+1 пользователь Hob Spillane написал:

Daniil Moskovtsov

unread,
Nov 6, 2013, 6:37:39 AM11/6/13
to mock...@googlegroups.com
Also maybe you know the way how to use capturing in refactoring friendly way? e.g:       
mock(model.taskModel).method('someMethod').args(capture(myCapture));


вторник, 5 ноября 2013 г., 16:36:07 UTC+1 пользователь Hob Spillane написал:
It's been a while, but I think what you're looking for is:
Reply all
Reply to author
Forward
0 new messages