jQuery in Action
[Logo] JavaRanch » JavaRanch Saloon
  Search | FAQ | Recent Topics | Hot Topics
Register / Login


Win a copy of Flex 4 in Action this week in the Flex forum!
Reply Bookmark it! Watch this topic JavaRanch » Forums » Other Languages » Groovy
 
RSS feed
 
New topic
Author

Unit Testing and Accessing Private Methods and Instance Variables

Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Messages: 954

Hi!
Currently, Groovy allows for access of private instance-methods and variables from outside the class. This is convenient in certain unit test scenarios, since it allows me to write simpler tests without having to use a testing framework (like PowerMock). However, as far as I understand this is basically a bug in Groovy (see http://jira.codehaus.org/browse/GROOVY-1875).
I fear that if I use this "feature", my unit tests will break the day Groovy 2.0 (or the version in which this is fixed) is released.
My question is: Does anyone have any experiences to share on how to solve this issue in Groovy?

I already know about PowerMock and I also know how to use Java reflection - I am wondering if there is a more "Groovy", a more elegant, way of doing this without relying on the above mentioned bug?
Many thanks in advance!
 
jQuery in Action
 
 
Reply Bookmark it! Watch this topic JavaRanch » Forums » Other Languages » Groovy
 
RSS feed
 
New topic
JProfiler
Get rid of your performance problems and memory leaks!