标签:bat dos 自动化测试 testcomplet
TestComplete作为一个软件自动化测试的IDE,留有少量接口供不同的人在不同的场景下运行项目,那么如何在windows的Dos下启动它并执行它的项目呢?
下面是TestComplete 提供的Command line:
TestComplete.exe [file_name [/run
[(/project:project_name) |
(/project:project_name /projectitem:item_name) |
(/project:project_name /test:test_name) |
(/project:project_name /unit:unit_name /routine:routine_name)]
[/exit]] [/SilentMode [/ErrorLog:File_name]] [/ExportLog:File_name]
[Timeout:Time_in_seconds] [/ForceConversion] [/ns]
上面命令的意思已经很明确了,就不一一介绍里面的参数了……
下面就根据上述的命令,写一个可指定时间和测试模式去执行TC项目的bat脚本,大致思路是:用set /p命令定义一个可接收输入值的变量,然后将改变量值与当前时间对比,约定时间的格式,if判断相等就执行,否则就等待~
具体batch脚本如下:
@echo off @echo /**************** begin *************/ ::author Alan_Y set /p executeTime=Please input the execution time(format:hhmm ,such as 1930): set /p projectModel=Please input project model(1:TestItems , 2:Main): set TCexePath=E:\software\TestComplete10\TestComplete.exe if %projectModel% EQU 1 ( set projectPath="E:\Learning\AutoTest\AutoTest.mds" ) else ( set projectPath="E:\Learning\AutoTest\AutoTestSuit.pjs" ) @echo. @echo TestComplete.exe path: %TCexePath% @echo. @echo Project path: %projectPath% @echo. set /a Timer=1 set sign=: :LOOP rem get the current time set currentTime=%time:~0,2%%time:~3,2% if %Timer% EQU 1 ( @echo the current Time: %currentTime:~0,2%%sign%%currentTime:~2,2% @echo the execute Time: %executeTime:~0,2%%sign%%executeTime:~2,2% @echo. ) else ( rem wait for 60s ping -n 60 127.0.0.1>nul 2>nul @echo the current Time: %time:~0,2%%sign%%time:~3,2% @echo the execute Time: %executeTime:~0,2%%sign%%executeTime:~2,2% @echo. ) if %currentTime%==%executeTime% ( rem kill TC process taskkill /F /IM "TestComplete*" rem run TC and execute project if %projectModel% EQU 1 ( start %TCexePath% /r /e %projectPath% ) else ( start %TCexePath% %projectPath% /r /p:AutoTest /t:"Script|fMain|main" )else ( set /a Timer=%Timer%+1 goto LOOP ) @echo /***************** end **************/
运行的效果如下:
/**************** begin *************/
Please input the execution time(format:hhmm ,such as 1930):1830
Please input the project model(1:TestItems , 2:Main):2
TestComplete.exe path: E:\software\TestComplete10\TestComplete.exe
Project path: "E:\Learning\AutoTest\AutoTest.mds"
the current Time: 15:35
the execute Time: 18:30
the current Time: 15:36
the execute Time: 18:30
the current Time: 15:37
the execute Time: 18:30
……直到执行
本文出自 “Alan_Y (Upspringing)” 博客,请务必保留此出处http://alany.blog.51cto.com/6125308/1672916
标签:bat dos 自动化测试 testcomplet
原文地址:http://alany.blog.51cto.com/6125308/1672916