I'm learning Groovy as I develop this project so I'm not sure of my ground.
I have an assertion like so:
assertThat( spyCH.getLoopCount() ).isEqualTo( 1 )
There is no explicit method getLoopCount()
, but there is an instance variable loopCount
in the CH
class. Groovy automatically creates getters and setters.
I declared CH
instance variable loopCount
like so
def loopCount // i.e. "type undefined" (as yet)
Actually this got to the value 11. And I got the following fail:
org.junit.ComparisonFailure: expected:<1[]> but was:<1[1]>
Obviously the result is being interpreted as a String. I then changed the instance variable to
int loopCount
... but I still get the same String comparison
Then I changed the test line to:
assertThat( (int)spyCH.getLoopCount() ).isEqualTo( (int)1 )
... but I still get the same fail line.
Is there anyone out there who knows how you can force AssertJ to do an int
/Integer
comparison in Groovy? (NB they're the same in Groovy: it has no primitive values).