How to automate test cases which need to be run in a clean OS

July 11, 2011 by
Filed under: automation, test 

Sometimes we need to automatically run some test cases which need to be run in an clean os. Such as application software installation benchmark. If you’d like to test performance of office installation under Microsoft Windows with different antivirus installed. The software installation is a test case, and it should be run in a clean OS.  Here’s the tools and steps. (works on Microsoft Windows XP).

4 Tools need to be prepared:

Grub4dos:  used to load dos image (modify default boot into OS in menu.lst).

Maxdos image (maxdos.img): which is extracted from max dos, and can be used to boot in to pure dos from grub4dos. Also you can use any other dos image which can boot into dos instead. (Images in vFloppy is recommended too)

Win Image: which we need to use for changing content in dos image file. We modify autoexec.bat in dos image to restore OS automatically and reboot.

Ghost: which we need to restore OS ghost image automatically.

5 Steps to automate test cases which need to be run in a clean restored OS:

1. Prepare a clean os, and make a ghost image (ghost\win.gho).

Before make the ghost image,  put your test script (such as start.script.bat) caller file to the  start-up menu in OS.  So that the script will be run automatically once upon reboot.

Make sure you windows system is in NTFS partition, and prepare a FAT32 partition, copy the ghost image win.gho to the FAT32 partition (ghost\win.gho) so that in pure dos we can read and restore the ghost image.

2. Modify c:\boot.ini to boot into grub (follow the readme of grub4dos to install grub on your system before this step).

[boot loader]
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /noexecute=optin /fastdetect

3. Edit grub boot configs to automatically boot into maxdos image

title restore by MAXDOS
find --set-root --ignore-floppies /boot/maxdos.IMG
map --mem /boot/maxdos.IMG (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)

4. Maxdos boot into into DOS automatically.

5. In the dos imaged (maxdos.img), modify the autoexec.bat to restore ghost automatically. (You need first extract files from maxdos.img by Win Image, then modify the files, and put the files back to the img file):

ghost.exe -clone,mode=pload,src=c:\ghost\win.GHO:1,dst=1:1 -fx -sure -rb

Plus, if you need to run several different cases, each case need to be run in a clean environment. You can do it in your start.script.bat as the following link:

How to automate test cases need reboot: a simple script solution

Digg This
Reddit This
Stumble Now!
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)


One Comment on How to automate test cases which need to be run in a clean OS

  1. Website Guru on Thu, 4th Aug 2011 3:40 pm
  2. Hi there, I really appreciate on the tips posted. It’s really applicable. And that’s right, it’s good to have automation as it gives less time and effort.