Within a helper method,the '*' of 1*mock.method() is recognized as multiplication sign

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Within a helper method,the '*' of 1*mock.method() is recognized as multiplication sign

Alex Luya
Hello,
        I tried to move some verifications from

then:
   1*mock.method()
   result.value>0

to helper method like this,

 def reusedVerification(Mock mock,Model result){
     assert 1*mock.method()
     assert result.Value>0
 }

but spock givens me an error like this

groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method
java.lang.Integer#multiply.Cannot resolve which method to invoke for [null]
due to overlapping prototypes between:
     [class java.lang.Character]
     [class java.lang.Number]
at .....
I think that the '*' sign was recognized as multiplication sign in helper method,how can I solve this problem?

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Within a helper method,the '*' of 1*mock.method() is recognized as multiplication sign

KARR, DAVID

Others can give a more authoritative response, but I think the main way to solve your problem is to not do that.  I believe it’s the case that certain semantics, like “interactions” as this represents, only work within the spec block itself.  I think a careful review of the user guide would lead to this by implication, although I don’t see an explicit statement of this.

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Alexander Luya
Sent: Wednesday, April 29, 2015 6:09 PM
To: [hidden email]
Subject: Within a helper method,the '*' of 1*mock.method() is recognized as multiplication sign

 

Hello,
        I tried to move some verifications from

then:
   1*mock.method()
   result.value>0


to helper method like this,

 def reusedVerification(Mock mock,Model result){
     assert 1*mock.method()
     assert result.Value>0
 }


but spock givens me an error like this

groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method
java.lang.Integer#multiply.Cannot resolve which method to invoke for [null]
due to overlapping prototypes between:
     [class java.lang.Character]
     [class java.lang.Number]
at .....

I think that the '*' sign was recognized as multiplication sign in helper method,how can I solve this problem?

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Within a helper method,the '*' of 1*mock.method() is recognized as multiplication sign

Kostis Kapelonis
What you ask is possible if you tell Spock explicitly that your code
deals with Mocks  like this

then:
   interaction {
   myCustomMethod(mock,result)
   }
  } //end of test method here

 def myCustomMethod(Mock mock,Model result){
      1 * mock.method()
      result.value == 0
 }


However IMHO if you really need a separate method for all your
verifications, perhaps you are verifying too many things.

On Thu, Apr 30, 2015 at 6:24 AM, KARR, DAVID <[hidden email]> wrote:

> Others can give a more authoritative response, but I think the main way to
> solve your problem is to not do that.  I believe it’s the case that certain
> semantics, like “interactions” as this represents, only work within the spec
> block itself.  I think a careful review of the user guide would lead to this
> by implication, although I don’t see an explicit statement of this.
>
>
>
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Alexander Luya
> Sent: Wednesday, April 29, 2015 6:09 PM
> To: [hidden email]
> Subject: Within a helper method,the '*' of 1*mock.method() is recognized as
> multiplication sign
>
>
>
> Hello,
>         I tried to move some verifications from
>
> then:
>    1*mock.method()
>    result.value>0
>
>
> to helper method like this,
>
>  def reusedVerification(Mock mock,Model result){
>      assert 1*mock.method()
>      assert result.Value>0
>  }
>
>
> but spock givens me an error like this
>
> groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method
> java.lang.Integer#multiply.Cannot resolve which method to invoke for [null]
> due to overlapping prototypes between:
>      [class java.lang.Character]
>      [class java.lang.Number]
> at .....
>
> I think that the '*' sign was recognized as multiplication sign in helper
> method,how can I solve this problem?
>
> --
> 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 [hidden email].
> To post to this group, send email to [hidden email].
> Visit this group at http://groups.google.com/group/spockframework.
> For more options, visit https://groups.google.com/d/optout.
>
> --
> 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 [hidden email].
> To post to this group, send email to [hidden email].
> Visit this group at http://groups.google.com/group/spockframework.
> For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.
Loading...