Hi Kevin.
Your first two ignored tests do not need a Spy, they run fine with a normal Calc object.
As for the other two tests, I do not understand what you are trying to test. And why do you need a Spy anyway (Spy is usually bad and a sign that you should refactor your code)? To me those two tests do not really make sense. If I knew why you think you absolutely need a Spy there, maybe I would think about what goes wrong there. To me it just looks like you want to see what you can do with a Spy anyway instead of a test which makes any logical sense.
Regards
--
Alexander Kriegisch
https://scrum-master.de
--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spockframewor...@googlegroups.com.
To post to this group, send email to spockfr...@googlegroups.com.
Visit this group at https://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.
Hi Kevin.
Your first two ignored tests do not need a Spy, they run fine with a normal Calc object.
As for the other two tests, I do not understand what you are trying to test. And why do you need a Spy anyway (Spy is usually bad and a sign that you should refactor your code)? To me those two tests do not really make sense. If I knew why you think you absolutely need a Spy there, maybe I would think about what goes wrong there. To me it just looks like you want to see what you can do with a Spy anyway instead of a test which makes any logical sense.
Regards
--
Alexander Kriegisch
https://scrum-master.de
void "gpars: Test with calc as spy, add a 2x number and a list of 2x numbers (parallel)"() {
setup:
calc = new Calc() {
@Override
Integer add(Integer n) {
return super.add(n * 2)
}
}
expect:
calc.add(3) == 6
calc.addListParallelGpars([-5, 4, 8]) == 20
}
This works nicely. Call it your home-grown spy if you like. I guess this should unblock you until you come up with a solution you like better. But I think this is simple and readable, so why not use it for good?
Regards