August 22, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

Automating Software Testing with Microsoft Hyper-V

  • November 19, 2008
  • By Jani Järvinen
  • Send Email »
  • More Articles »

Hyper-V is a technology that supports enterprise-scale virtualization, and it is also possible to automate it in powerful ways. Originally, Hyper-V came only with properly licensed versions of Windows Server 2008, but just recently, Microsoft announced a product called Hyper-V Server 2008, which is a free product to support virtualization, just like VMware's ESXi.

To use Hyper-V, you need modern hardware: Hyper-V requires both a 64-bit (x64) installation and virtualization support (such as IntelVT) from the processor. Thus, from Intel, you would need some of the latest Core processors or a Xeon processor. But, once these requirements are satisfied, Hyper-V is a big improvement over the same company's older Virtual Server.

Hyper-V provides good management tools already built in. The most important tool, called Hyper-V Manager, allows you to construct new virtual machines, change their settings, and connect to them to view their screens (see Figure 3).



Click here for a larger image.

Figure 3: The Hyper-V Manager utility.

Although the Hyper-V Manager is a nice management tool especially for simpler usage scenarios, it unfortunately does not support automation through scripts or code. For that, you would need a separate management tool, called the System Center Virtual Machine Manager, or System Center VMM. Although this product sounds expensive, it luckily is not. The previous version Virtual Machine Manager cost around $500, and the same could be expected from its successor, the newer 2008 version. At this writing, the 2008 version is still in the beta stage.

With Virtual Machine Manager in place, you will get access to a set of PowerShell commands that let you automate all operations that the graphical management console of Virtual Machine Manager can do. In fact, when you operate VMM's management console thru wizards, on the last page you have to option to show the PowerShell script that would complete the exact same task as the wizard.

A Testing Procedure

Say that you have a.NET application you would like to test as automatically as possible. Armed with a Hyper-V environment and System Center Virtual Machine Manager installation in place, you can write a PowerShell script that fully automates your testing.

For instance, say that your application is a server-side application that talks to a database, does certain calculations and data manipulations, and then writes the results to a log file. If you wanted to test this application manually, you would copy it to a (virtual) testing machine, run the application, and then check the results once they are available.

If the application takes a long time to run—for example, several hours—you might want to refine the testing process even further. For instance, you could write code to send an email saying that your application has finished executing.

Given this flow of logic, your completed testing procedure could have the following steps:

  1. Start a testing virtual machine, and return it to a known, clean state.
  2. Copy and/or install the application to the virtual machine.
  3. Run the application and wait for the results.
  4. Take the log file and copy it to a safe place for later analysis.
  5. Send a notification to the tester(s) telling that there are results to analyze.

Note that although this article talks from the perspective of .NET and Visual Studio development, you actually could use Hyper-V–based testing automation for applications developed with any Windows development tool, be it Embarcadero/CodeGear, Java, PHP, or anything else.

Similarly, you could even test web applications, provided that you have a proper client to access the application automatically. For instance, Visual Studio Team System has support for web tests, which could be exactly what you need.

Next, you are going to learn how to write PowerShell commands to automate the above five-step testing process in a Hyper-V environment (see Figure 4).



Click here for a larger image.

Figure 4: SCVMM's PowerShell interface lets you automate virtual machine operations.

Automating Hyper-V Using PowerShell

When you install System Center Virtual Machine Manager (VMM) management features on a server, you get access to a specially tailored PowerShell command prompt with the proper snap-ins already registered.

VMM supports many different commands thru the PowerShell interface. Just like all other PowerShell commands, VMM's commands are named using a verb-noun pair, such as Get-VM, Restore-Checkpoint, and so on.





Page 2 of 4



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel