For one project we developed and tested software on Windows OS. It is used with coolers, motherboards, keyboards, mice and other hardware and peripheral devices. When a new build is released, QA engineers must have the:
- Ability to start testing from strictly the same OS configuration.
- Ability to deploy the build on a system that is as close to a real PC as possible.
Installing the OS from a clear ISO image is too time expensive. A virtual machine is a little better because it’s faster. But as we test hardware (HW) utilities, VM is not the best solution. We need to check that certain devices work with certain drivers and the HW environment.
We use VHD files for testing hardware on Windows.
VHD (Virtual Hard Disk) is a file format which represents a virtual hard disk drive (HDD). It may contain what is found on a physical HDD, such as disk partitions and a file system, which in turn can contain files and folders. It is typically used as the hard disk of a virtual machine.
VHD technology has three main benefits:
- A VHD file is a common file
It can be copied and deployed on another machine. You may store as many VHD files on your hard drive (or SSD) as you need. Each VHD contains a specific configuration. It is enough to double-click one of them and you are inside another file system in a mere moment.
- It is fast
After you enter into a VHD file you start to work exactly as on another file system. After you reload a PC with the VHD you are in a completely different environment. The desktop and icons, partitions, registry, user’s settings, caches, tmp-files are all unique to the VHD. The mouse moves as fast as it moves on a real PC. No lag as it can be with VM. And, you have access to the real filesystem.
- Officially supported
VHD is officially supported and developed by Microsoft. This technology is native for Windows 7 and up to date. You do not need to install additional software. VHD files will be open even on newly installed Windows systems.
How we use VHD for testing
There is a lot information on how to create VHD file out there. But if you do it often, automation is the way to go. This script is written on PowerShell and hosted on a Microsoft server.
Step 1. Copy an ISO image with the clean Windows copy to certain place on hard drive.
Step 2. Open PowerShell.
Step 3. Run the script, then specify the path to the ISO we’ve prepared.
Step 4. Press Enter and wait for a few minutes.
The script compiles and stores a VHD file that contains a clear Windows version (Screens 1, 2). This file we may use by itself and as base for further VHD tuning.
We rarely use clear VHD. For testing, an environment with drivers and additional software is much more useful.
There is a really simple way to add to a VHD file needed software. We just 1) Reload to system stored in VHD file and 2) Install what we need.
All changes are saved into VHD file. Reload the PC after finishing.
Often we integrate software for debugging applications into VHD files (some IDE depends on project) and software for remote connections. If a bug is found, the IDE helps the developer to fix bugs quickly, directly on specific environment.
The remote connection is used when we work with testing software on another PC. When we start to deploy VHD files we may lose control after reloading. The tuned remote connection already has an ID that holds connections with a remote PC even after it is reloaded.
After we have the ready-to-use VHD, we start to testing a new build.
- Open the Windows boot settings (we use EasyBCD tool) and specify the path to boot (Screen 3).
- Reload PC.
- Test the device on freshly prepared OS.
- If a bug is found, just backup current VHD file and mark it something like “Issue #1” and hand it over to the developer.
That’s it. Hope these simple practices save you lots of hours and make your software more reliable.
And, of course, do not forget renew VHD files if updates are available.
Screen 1. Compilation of VHD with the script.
Screen 2. The list of different Windows sources in VHD files.
Screen 3. Specify path to boot from VHD file with specific environment.
Author: Anton Noga