We had already a running Hudson build server. The jobs running on it where mainly build, deploy and test scrips “written” in ant. The compiled binaries and some installation scripts where moved (using SCP) to a server VMWare image (the script installed a new database, created a new db schema etc.). Each build ends with some JUnit tests verifying the quality of the build.
The next step was to establish a HMI-test environment for our FAT client application with a production near server and client installation.
Tooling
We looked for a tool that is able to provide a professional application to write UI tests. Beside that, it should support scripted testing and generate HTML based test results. After some (short) investigations we selected QFTest.
Environment
The basic setup consist of the Hudson build server running on a MacPro. For the client and server installations we used production near VMWare Fusion images running on the same machine. For each type of production environment we had one Client (Windows XP) and one server (Oracle Enterprise Linux 64Bit) image.
Snapshots
The first thing was that we needed to provide a stable starting point for the UI tests. We decided to use VMWares snapshot mechanism for that – which is obvious. We created a raw initial snapshot called Basic Setup. Hudson, in case of a successful build, deploys the binaries to it (using vmrun and simple BAT-files) and created a UITest Basic snapshot for the tests. Each UI test will revert to this snapshot first.
The following bash script does all that. It is called by an Ant script triggered by a Hudson build job. It collects the test results as well and copies them to the host. The Hudson build job can use them as build artifacts or documentation.
Script
#!/bin/bash here="`dirname \"$0\"`" cd "$here" PATH=$PATH:/Library/Application\ Support/VMware\ Fusion/ CLIENT=/Volumes/Virtual\ Maschines/NBX\ BuildServer/NBX\ Pluto\ Test\ Client.vmwarevm/ClientDev.vmx E_NO_ARGS=65 doTest() { local path=$1 local file=${path##*/} local base=${file%%.*} echo --- reverting to snapshop UITest vmrun -T fusion revertToSnapshot "$CLIENT" UITest echo --- starting VM vmrun -T fusion start "$CLIENT" echo --- Deleting directories vmrun -T fusion -gu Administrator -gp password deleteDirectoryInGuest "$CLIENT" "C:\\temp\\QFTReport" &> /dev/null vmrun -T fusion -gu Administrator -gp password deleteDirectoryInGuest "$CLIENT" "C:\\temp\\QFTest" &> /dev/null vmrun -T fusion -gu Administrator -gp password deleteFileInGuest "$CLIENT" "C:\\temp\\QFTReport.zip" &> /dev/null vmrun -T fusion -gu Administrator -gp password createDirectoryInGuest "$CLIENT" "C:\\temp\\QFTest" echo --- running test $1 vmrun -T fusion -gu Administrator -gp password copyFileFromHostToGuest "$CLIENT" "$1" "C:\\temp\\QFTest\\$file" vmrun -T fusion -gu Administrator -gp password copyFileFromHostToGuest "$CLIENT" "/Users/hudson/Documents/hudson-workspace/ui-continuous/co/1/qftests/uitest.qft" "C:\\temp\\QFTest\\uitest.qft" vmrun -T fusion -gu Administrator -gp password runProgramInGuest "$CLIENT" "qftest.exe" "-batch" "-runlog" "C:\\temp\\$base\\log.qrl" "-report" "C:\\temp\\$base" "C:\\temp\\QFTest\\$file" vmrun -T fusion -gu Administrator -gp password runProgramInGuest "$CLIENT" "C:\\temp\\install\\zip.exe" "-r" "C:\\temp\\$base" "C:\\temp\\$base" vmrun -T fusion -gu Administrator -gp password CopyFileFromGuestToHost "$CLIENT" "C:\\temp\\$base.zip" "$file.zip" echo --- Cleanup vmrun -T fusion -gu Administrator -gp password deleteDirectoryInGuest "$CLIENT" "C:\\temp\\$base" vmrun -T fusion -gu Administrator -gp password deleteDirectoryInGuest "$CLIENT" "C:\\temp\\QFTest" vmrun -T fusion -gu Administrator -gp password deleteFileInGuest "$CLIENT" "C:\\temp\\$base.zip" } if [ $# -eq 0 ] then echo "Please invoke this script with one or more command-line arguments." exit $E_NO_ARGS fi for i in $* do doTest "$i" done
Part 2 will show the ANT scripts