nUnit testing for forms in VB.net
I'm new to unit testing, and with all the study and research i've done, no one has explained this important part of the proces, and I just can't get my mind wrapped around it!
I'm working in Visual Studio 2003, using Visual Basic
If I have a FORM with controls on it - let's say a button. I write a bunch of code in the click event of the button, and I want to test that code.
As they say, I'm supposed to write a test for it, so i create a new class and set it up as a testing class (i understand the basics of this ok).
it seems that in order to test the code behind that button, i have to first instantiate a copy of that form. Seems wierd, but i can do that:
dim myForm as new form
The problem I run into is that a button click event on that form is Private by default. In order to get to that event, i.e.
dim myE as new EventArgs
I have to make it public (bad practice) or write a public method that invokes the private method. IS THIS RIGHT?
If there are any locally declared variables inside that click event code, and i need to test them, I can't get to them - they're not visible. DO I MAKE THEM ALL PUBLIC? or do I ADD A BUNCH OF PROPERTIES TO HOLD THIS INFORMATION, JUST SO I CAN TEST IT? (This just seems like it adds an enormous amount of complexity to the project.)
All the examples ive seen on the net deal with class modules, not forms. I have my share of class modules too, but it's the forms that have GOT MY MIND BENT!
Can anyone help?