Archive for the ‘Automation’ Category


Pex 0.5 Available for Download

0

PexLogo Pex (from the Microsoft Research Lab) has finally been released the public. Pex 0.5 can be downloaded here.

What is Pex?


“Pex (Program EXploration) is a white-box test generation tool. Given a hand-written parameterized unit test, Pex analyzes the code to determine relevant test inputs fully automatically. The result is a traditional unit test suite with high code coverage. In addition, Pex suggests to the programmer how to fix bugs.”


I haven’t had a chance to dive in but I’m pretty excited to see how this can speed up production of writing white box tests and/or increase the code coverage on QA’s side.


At the end of the day it’d be nice to see this in the developers’ hands and not mine. Baby steps though…


Read more about Pex here.


Get an ear full of Pex with a great Hanselminutes Podcast entitled “Pex with Jonathan ‘Peli’ de Halleux and Nikolai Tillmann“.


Why We Should Drop the "Unit" in "Unit Test Frameworks"

1

brentUnit

I hate it.


Unit test this. Unit test that.


Let’s put “unit” in our testing framework so we can test “units” cuz that’s all ANYBODY is EVER going to test.


Testing outside of the “unit” is forsaken. Thou shalt never test more than a unit. Test more than a unit and ye shall be pelted with stones and crucified.


Let’s see… What do we have here for unit test frameworks:


brentUnit (even Brent Strange can have a unit testing framework)
JUnit (notice the word unit)
nUnit (look at me, I test units)
mbUnit (I’m a follower, I can’t think outside of the box. Uhm…let’s test units.)
csUnit (CHEESE & RICE, this is INSANE)


OH HELL…Just go here for the gi-hugey list:


http://en.wikipedia.org/wiki/List_of_unit_testing_frameworks


You back? See what I mean? There’s like one-cajillion testing frameworks that are for “Unit Testing”.


Unit, unit, unit. It’s freakin’ beyond dumb.


Tell me…What happens once this developer phase of “Oh, I gotta go write some unit tests, with my unit test framework so my code is better” evolves to tests beyond “unit”? You know, like writing some tests that are “integration” or “functional? It’ll happen people.


IT’S HAPPENING PEOPLE.


I, and others have been using “unit testing” frameworks as an automation test harness for years now. All kinds of tests.. Tests that aren’t “unit”.


Yeah, insane. Unheard of I know. What? You going to crucify me now?


Drop the unit. Get over it. These are “Testing frameworks”.



P.S.
Microsoft, nice namespace: Microsoft.VisualStudio.TestTools.UnitTesting


P.P.S
Don’t give me any crap about how “unit testing frameworks” are for developers. Good one rocket scientist…Let’s create separate frameworks to basically do the same thing. One for Dev, one for QA. Brilliant…


Six Different Ways To Execute Tests in Visual Studio 2008

0

I remember the 1st time I tried to kick-off a “unit test” from Visual Studio 2005. I had to defer to the Web, I couldn’t figure it out. A year later and through everyday use of VS 2005 and VS 2008 I’ve slowly discovered various ways to get those tests rolling. Here are 6 different ways to start a test in Visual Studio 2008:


“Test Tools” Toolbar


image




Context Menu


clip_image001



Keyboard Shortcuts

Ctrl+R, Ctrl+T: Execute tests in current context
Ctrl+R, Ctrl+C: Execute tests in current test class
Ctrl+R, Ctrl+N: Execute tests in current namespace
Ctrl+R, Ctrl+A: Execute all tests in solution
Ctrl+R, Ctrl+D: Execute the tests in the last test run
Ctrl+R, Ctrl+F: Execute the failed tests of the last test run


Test List Editor


image



Test Results Pane


image



“Test” Menu


image



ArtOfTest Now Has a Record/Playback Tool

0

DesignCanvas

ArtOfTest, creators of the browser automation framework WebAii, released a record/playback tool that works from within Visual Studio 2008! The beta release of “Design Canvas 1.0” fills a huge gap in the ArtofTest automation solution. Not only has ArtOfTest provided this great functionality, but this functionality looks really, REALLY cool. See for yourself with their 30 second QuickStart videos. I haven’t had time to dig into it myself yet but I’m really excited to do so. From an automation engineer that spends much of his day writing tests in Visual Studio, watching these videos made my mouth water. I’m thinking that ArtOfTest is going to take a lion’s share in the automation space in the next few years. They’ve chosen a great platform (.NET), a great IDE (VS 2008), and are working toward providing test and automation solutions for new technologies such as SilverLight.


Silverlight 2 API and UI Automation

0

Microsoft SilverlightJeff Wilcox at Microsoft hat put together a great article entitled “Silverlight Unit Testing” that shows us how to use the newly available unit testing framework that comes with Silverlight 2 (currently in Beta 1). The framework has the ability to test the API as well as run the tests in all the browser that support Silverlight 2!


Check out Jeff’s video-cast entitled “walkthrough of the control unit tests” for a quick peek at how this stuff works.


This is really exciting from an automation standpoint. As an automation engineer I always fear new technologies and their hurdles that might make software not so automatable….much like that darn Flash. Here we are almost 10 years later and the best thing we have to “help” automate Flash is iMacros.


How to Convert a Visual Studio 2005 non-Test Project to a Test Project

1

Have you ever been in the position where you want to convert an already existing Visual Studio 2005 project to be a Test Project so that you can write and run unit tests? There is no simple way, but there is a hack.


Assuming that you are using a version of Visual Studio that supports Testing (e.g. Team Edition for Software Testers) here is how to do it:



  1. Add the following .NET Reference to the project:
    Microsoft.VisualStudio.QualityTools.UnitTestFramework
  2. Put in the following using directive in the .cs file that contains your tests:
    using Microsoft.VisualStudio.TestTools.UnitTesting;
  3. Create a Test List, this will generate the .vsmdi file (This is the file that opens your Test Manager tab):

    1. Click Test in the top menu
    2. Select Create New Test List:
      image

    3. Notice in the Solution Explorer that the Project now is wrapped in a Solution and the .vsmdi file has been created:
      image

  4. Setup your test configuration file (.testrunconfig):

    1. In Solution Explorer right click the Solution Items folder, select Add, then select New Item
      image 
    2. In the dialog, highlight Test Run Configuration on the left and select Test Run Configuration on the right side
    3. Name the file accordingly and then click Add:
      image
    4. Notice the .testrunconfig file has been added to the solution
      image

  5. Close Visual Studio
  6. Open the project’s .csproj file in a text editor.
  7. In the top <PropertyGroup> node, change the <ProjectTypeGuids> node to read:
    <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

    If your using VB.NET your GUID should be:
    <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{F184B08F-C81C-45F6-A57F-5ABD9991F28F}</ProjectTypeGuids>


  8. Save and close .csproj file.
  9. Open the Solution up (.sln file).
  10. You are now ready to write tests.
  11. To run your tests:

    1. In Solution Explorer double click the .vsmdi file to open the Test Manager window
    2. Check the test you want to run
    3. Right mouse click the test and select Run Checked Test.

image




This problem is quite interesting due to the fact that the .vsmdi file and .testrunconfig exist at the Solution level and not the Project level. In the past this interesting fact was a small hurdle for our automation team because we needed to create a Visual Studio template for a Test Project, but Visual Studio only templates Projects and not Solutions (again the .vsmdi & .testrunconfig need to exist at the .sln level). I’ll save the explanation of that workaround for another day!


Silverlight Spy

0

imageI ran into another Silverlight snooping application today: Silverlight Spy


This one is pretty cool in the fact that you can point it towards a Web site/Silverlight application and it will allow you to peruse the plugin using i’ts XAML Explorer as well as change the properties and and actual XAML on the fly. Seeing tools like this tells me that automating a Silverlight application is easily doable. Flash on the other hand…an automation nightmare. I wish it would go away.



Here is the current feature list:




  • Convenient XAML object explorer
  • XAML object property grid allows for getting and settings property values
  • Regeneration of the XAML xml based on the object model
  • Statistics of used objects
  • Tracing facility for debugging Silverlight 1.0 applications

Download Silverlight Spy.


Silverlight Documentation.


Debug & automate any modal or modeless dialog with SWEA

0


Understanding how to get at the controls in a modal dialog box when using SWEA is something I never had to worry much about in the past; the SWEA example code took care of all of those that I had previously encountered. Recently I needed to automate a “Choose file’ dialog, and since there was no example, I had to buckle down to figure out how to get at the controls in that dialog. To understand the controls of this particular modal dialog, and also wanting to make sure I could handle all others I encountered in the future, I wrote some code that would dump all relevant things available in SWEA’s DialogControl class when the DialogActivatedEventHandler was fired. By doing this, when a dialog was presented, I was able to scrape all the control information out of the modal dialog. The following code in my explorerManager_DialogActivated method did the scraping and dumping:


if (this.Debug == true)
{
    Console.WriteLine
        (“–Modal dialog info——————–“);
    Console.WriteLine
        (“Modal Dialog Title: “ + dialogScene.Title);
    Console.WriteLine
        (“Modal Dialog ClassName: “ + dialogScene.ClassName);
    Console.WriteLine
        (“Modal Dialog DialogHWND: “ + dialogScene.DialogHWND);
    Console.WriteLine (“Modal Dialog XML: “ + dialogScene.Xml.ToString());
    Console.WriteLine
        (“—————-Controls in Modal dialog—————–“);
    foreach (DialogControl dlgCtrl in dialogScene.Controls)
    {
        Console.WriteLine(“Control name: ‘”
            + dlgCtrl.Name + “‘ is a type of: “ + dlgCtrl.GetType().ToString());
    }
    Console.WriteLine(“—————————-“);
}


With my new addition as noted above, when the DialogActivatedEventHandler was fired the explorerManager_DialogActivated method was invoked which resulted in the following informational console dump about my modal dialog:

—Modal dialog info——————–
Modal Dialog Title: Choose file
Modal Dialog ClassName: #32770
Modal Dialog DialogHWND: 5047980
Modal Dialog XML: <Dialog HWND=”5047980″ Title=”Choose file” Class=”#32770″><Window HWND=”7014084″ Title=”Look &amp;in:” Class=”Static”></Window><Window HWND=”5441378″ Title=”SMSIMG (C:)” Class=”ComboBox”></Window><Window HWND=”5900158″ Title=”” Class=”Static”></Window><Window HWND=”5572502″ Title=”” Class=”ToolbarWindow32″></Window><Window HWND=”8914906″ Title=”” Class=”ToolbarWindow32″></Window><Window HWND=”2623410″ Title=”” Class=”ListBox”></Window><Window HWND=”9963366″ Title=”” Class=”SHELLDLL_DefView”></Window><Window HWND=”7735164″ Title=”FolderView” Class=”SysListView32″></Window><Window HWND=”6293452″ Title=”File &amp;name:” Class=”Static”></Window><Window HWND=”6620914″ Title=”” Class=”ComboBoxEx32″></Window><Window HWND=”7735112″ Title=”” Class=”ComboBox”></Window><Window HWND=”4196138″ Title=”” Class=”Edit”></Window><Window HWND=”58918660″ Title=”Files of &amp;type:” Class=”Static”></Window><Window HWND=”14419712″ Title=”All Files (*.*)” Class=”ComboBox”></Window><Window HWND=”3016576″ Title=”Open as &amp;read-only” Class=”Button”></Window><Window HWND=”7276400″ Title=”&amp;Open” Class=”Button”></Window><Window HWND=”10946288″ Title=”Cancel” Class=”Button”></Window><Window HWND=”6227962″ Title=”&amp;Help” Class=”Button”></Window><Window HWND=”7079840″ Title=”” Class=”ScrollBar”></Window></Dialog>
—————-Controls in Modal dialog—————–
Control name: ‘Static_0’ is a type of: SWExplorerAutomation.Client.DialogControls.DialogStatic
Control name: ‘Static_1’ is a type of: SWExplorerAutomation.Client.DialogControls.DialogStatic
Control name: ‘Static_2’ is a type of: SWExplorerAutomation.Client.DialogControls.DialogStatic
Control name: ‘Edit_0’ is a type of: SWExplorerAutomation.Client.DialogControls.DialogEdit
Control name: ‘Static_3’ is a type of: SWExplorerAutomation.Client.DialogControls.DialogStatic
Control name: ‘Open as read-only’ is a type of: SWExplorerAutomation.Client.DialogControls.DialogButton
Control name: ‘Open’ is a type of: SWExplorerAutomation.Client.DialogControls.DialogButton
Control name: ‘Cancel’ is a type of: SWExplorerAutomation.Client.DialogControls.DialogButton
Control name: ‘Help’ is a type of: SWExplorerAutomation.Client.DialogControls.DialogButton
———————————————————


After extracting the control information I needed for my test from the console dump, in the same explorerManager_DialogActivated method I created a condition for the “Choose File” modal dialog that inserted a file location/name and then clicked the “Open” button:

//Manage the ‘Choose file’ dialog box
if (dialogScene.Title == “Choose file”)
{
if (dialogScene.ControlExists(“Edit_0”))
{
dialogScene.DialogEdit(“Edit_0”).Text =
            this.ChooseFileLocation;
}
if (dialogScene.ControlExists(“Open”))
{
dialogScene.DialogButton(“Open”).Click();
}
Check the automation of another modal dialog box off my list! …and even better, I’m now setup to dump information about any others that might cross my path.


Post navigation