StrataFrame Forum

Possible solution for testing the UI

http://forum.strataframe.net/Topic19257.aspx

By Scott Bressette - 9/10/2008

I think I found something really great but I want to make sure that it isn’t a bad idea. My situation is that I want to use Strataframe for my windows development but we use Test Driven Development (TDD) in VB6. Microsoft has made testing the UI impossible with the build-in Unit Tests, so one is only left with the Active Accessibility Architecture which was never meant to be used for testing.



I was quite disappointed by all of this, but I think Strataframe can help me. The issue for .Net Unit Tests is that the build-in tester is blocking (or is block by) the thread running the windows app and the properties of a form is only initialized on the load of the form (hence the InitializeComponent(); in every contructor). Ultimately, this means you can’t test that your UI actually hooks to anything and you can never automate passing your user tests.



So, I tried initializing my test like this:

[ClassInitialize()]

public static void MyClassInitialize(TestContext testContext)

{



Globals.MainStart();



}

My Globals.MainStart() mimics the “Main” start up function in the app and it is “Global” because all of my unit tests initialize the app using this static class.



Then in the Globals class I have my ShowGateway method that Strataframe will call when I call “StrataFrameApplication.RunApplication()” at the end of the MainStart() method.



private static void ShowGateway(ShowGatewayEventArgs e)

{

e.ShowGatewayAfterMainFormClose = false;

e.ExitApplication = true;

}



The key thing is that I tell Strataframe to “e.ExitApplication = true;”. It appears Strataframe “handles” the blocking thread of my test and now all of my unit tests fire before the app actually closes. So, I can write tests to make sure that max field lengths are set, localization keys are used, or test any property of a control that otherwise would be impossible (or at least really hard) to test.



So, my question is, is it ok to set e.ExitApplication and expect the process to still be active to test data bound screens? I hope so because this solves a big problem for me!
By William John Tello - 9/11/2008

*bump*
By Trent L. Taylor - 9/11/2008

Honestly I do not know with out seting this up and testing it myself.  We take an entirely differently approach with our UI unit testing by setting up regression tests.  We use Automated QA for all of our UI testing which has worked well for us...but I cannot give you a straight answer without first going through and testing this myself...which is probably not going to happen in this exact scenario as I do not use the same unit testing software as you do.

The first thing I would recommend is just setting it up and giving it a go...if you run into any issues then we can go from there and see if there might be a simepl work around, but past that I am not going to be much help.  Sorry Ermm

By Scott Bressette - 9/11/2008

Thanks Trent. I suspected this was a bit unusual, I was just hoping there wasn’t a panic response of “don’t do it!” I’ll let you know if I have any problems but so far it has worked flawlessly.

To see my problem just try to make a unit test from Visual Studio to test if a form’s text box is bound to a business object property field. You’ll see that you are blocked in about 12 ways from getting to that screen and property. My method makes it so, as the developers are doing their normal TDD on the business objects, they can reach out to the UI and check that their screens are hooked up correctly too.

We are using the security and localization and having the ability to ensure that every property is set, every control is localized and everything is secure before it goes to our QA department is an incredible time saver.

We have an old copy of Automated QA but I didn’t want to get into the complexity of automation scripts and introduce another application everyone needs to learn. Does the current version of Automated QA let you test such things as localization keys and security settings? Or, do you have make scripts that test “if it was set right, then this would be true” type tests.

By Trent L. Taylor - 9/11/2008

Does the current version of Automated QA let you test such things as localization keys and security settings?

Yes...we have this need as our medical software will support both English and Portuguese...they really have made a lot of good enhancements even since we have been using them.  They aren't perfect, but we can get the job done and sometimes a little elbow grease is required...but all in all we are having good luck with them.

By Scott Bressette - 9/11/2008

That's good news. I'll let my QA department know that they should investigate getting a new copy of it. Thanks for the info.