Invoking private methods

Class library usage, coding and language questions.
mgrinder
Posts: 2
Joined: Wed May 14, 2008 5:07 pm

Invoking private methods

Post by mgrinder » Wed May 14, 2008 5:09 pm

Can Ranorex invoke private methods on a .NET control?

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Post by Support Team » Thu May 15, 2008 9:56 am

Technically, invoking private methods would be possible. However, it is not supported since the names of private methods could interfere with the names of public methods.

Anyway, private methods are usually private for a reason. If you need to call the method, why not make it public or provide a public method that calls the private one?

Regards,
Alex
Ranorex Support Team

mgrinder
Posts: 2
Joined: Wed May 14, 2008 5:07 pm

Post by mgrinder » Thu May 15, 2008 4:24 pm

Support Team wrote:Technically, invoking private methods would be possible. However, it is not supported since the names of private methods could interfere with the names of public methods.

Anyway, private methods are usually private for a reason. If you need to call the method, why not make it public or provide a public method that calls the private one?
Because making the method public would require justifying the change to development. The developers are very resistant to making changes even if it makes QA's job easier. You obviously haven't actually used your product to test a real application. :-)

Well, I guess that rules out Ranorex for my particular set of problems.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Post by Support Team » Thu May 15, 2008 5:24 pm

mgrinder wrote: Because making the method public would require justifying the change to development. The developers are very resistant to making changes even if it makes QA's job easier.
Well, I think you got me wrong. What I meant is that usually there is no sense in calling private methods since they are not meant to be called from outside and may be changed or deleted at any time in development. If a private method should be callable, in other words if it should be part of the API, it needs to be marked public.

However, I can understand that there are reasons one would like to call private methods for testing, e.g. to set objects to a certain state. That's why I added this feature to our wanted features list for the next Ranorex version.

Regards,
Alex
Ranorex Support Team