In the following video, towards the end, someone asked that FlexUnit assumes functions and methods are to be public when tested.
The speaker replied (@ 52:25), to use Delegate classes, which are linked in when being tested.
Can someone show me an example of this? Thanks.
Delegate classes will allow you access to some internals of the Adobe Flex component framework. They do so by capturing events and allowing you to replay them. If this is the specific scenario you need to test, then delegate classes can work for you.
However, in general, we don't test private methods. In ActionScript there is no way for an external class to gain access to the private members of another, so these get tested only by their individual calls from public members.
Mike, thanks for the reply!
As I am new to unit testing, things are still solidifying. I do understand that Unit Testing, “tests the smallest functional unit of code”, which are methods and functions. However, I incorrectly assumed that *every* method needed to be tested *directly*. Hence, I thought all methods would have to be public. So that would have blown encapsulation out of the water. Now I understand from your reply, that private methods get tested indirectly from public methods. And that seems more ideal.