分类:
2011-03-26 19:08:46
VMWare Workstation在自动化测试可以得到很好的应用,原因在于其拥有强大的快照功能,能通过命令行方式方便的执行类似于Ghost的操作,这在准备干净的测试环境时用途非常明显。去年VMWare推出的最新Workstation7为Windows7提供了很好的操作平台,为Windows7的稳定运行提供了保障。
1. 命令行启动VMWare Workstation:
C:\Program Files\VMware\VMware Workstation\vmware.exe [-B] [-n] [-x] [-X]
[-t] [-q] [-s
Option |
Description |
-n |
Opens a new Workstation window. |
-B |
(Windows hosts only) Opens a new Workstation window but hides the sidebar and toolbars. Only the tabs of open virtual machines are shown. Using this option has the same effect as clicking the Workstation icon in the upperleft corner of the Workstation window and choosing Hide Controls from the menu that appears. |
-t |
Opens a virtual machine or team in a new tab in the existing Workstation window. |
-x |
Powers on the virtual machine when Workstation starts. This is equivalent to clicking the Power On button in the Workstation toolbar |
-X |
Powers on the virtual machine and switches the Workstation window to full screen mode. |
-m |
Starts the program in quick switch mode. |
-q |
Closes the virtual machine’s tab when the virtual machine powers off. If no other virtual machine is open, it also exits Workstation. This option is useful when the guest operating system can power off the virtual machine |
-s |
Sets the specified variable to the specified value. Any variable names and values that are valid in the configuration file can be specified on the command line with the -s switch |
-v |
Displays the product name, version, and build number |
|
Launches a virtual machine by using the specified virtual machine or team configuration file (.vmx or .vmtm file). |
2. vmrun命令行工具:
对于自动化测试有如下实用命令行(-T代表目标类型,后更参数ws代表Workstation):
l Power Commands:开启、停止、重启、挂起虚拟机
vmrun -T ws start|stop|reset|suspend “path_of_wmx_file”
start,有两个参数gui|nogui,前者是默认参数,参数加在末尾
stop/reset/suspend有两个参数hard|soft,hard代表执行命令前不运行wmtools文件夹中对应的批处理文件,soft代表执行命令前运行批处理文件,参数加在末尾
l Snapshot Commands:创建、删除、还原快照
vmrun -T ws snapshot|deleteSnapshot|revertToSnapshot “path_of_wmx_file” “snap_shot_name”
Snapshot还有一个命令是listSnapshots,列出所有快照名
l Record and Replay Commands:
vmrun -T ws -gu
vmrun -T ws -gu
上述命令配对使用。
l Guest Operating System Commands:
此类型命令较多,摘取部分较有价值的列举如下:runProgramInGuest | runScriptInGuest | listProcessesInGuest | killProcessInGuest | fileExistsInGuest | deleteFileInGuest | renameFileInGuest | createDirectoryInGuest | deleteDirectoryInGuest | listDirectoryInGuest | copyFileFromHostToGuest | copyFileFromGuestToHost | captureScreen