开发人员用的提交测试环境的AutoIT脚本

主要功能就是依次检查各个步骤,确定该做的工作都已经完成,如果没有完成,就自动打开相关的工具,并等待完成。

代码如下:

 

;各个文件的位置
$vss = "C:\Program Files\Microsoft Visual Studio\COMMON\VSS\win32\SSEXP.EXE"
$ie = "C:\Program Files\Internet Explorer\iexplore.EXE"
$plsql = "C:\Program Files\PLSQL Developer\plsqldev.exe"

;是否已经将所有文件提交VSS?
$haveCheckedIn = MsgBox(4, "VSS 检查","是否已经将所有文件提交VSS?")
;->否;打开VSS,自动输入用户名密码,进入
If $haveCheckedIn = 7 Then
	Run($vss)

	WinWaitActive("Visual SourceSafe Login")
	Send("hq100545")
	Send("{Enter}")

	WinWaitActive("Visual SourceSafe Explorer -- vss60cn");

	;等待完成…………
	MsgBox(0,"VSS 检查","完成之后请继续!")

	If WinExists("Visual SourceSafe Explorer -- vss60cn") Then
		WinClose("Visual SourceSafe Explorer -- vss60cn")
		WinWaitClose("Visual SourceSafe Explorer -- vss60cn")
	EndIf

EndIf

;是否存在SQL文件(.sql)?
$haveSQLFiles = MsgBox(4, "SQL 检查","是否有需要提交的SQL文件?");

;如果有SQL的话,则需要验证SQL的有效性
if $haveSQLFiles = 6 Then
	;是否已验证SQL的有效性
	$CheckedSQL = MsgBox(4,"SQL 检查","是否已经验证过SQL的有效性?")
	;->否:打开pl/sql developer,并以sys身份登录
	if $CheckedSQL = 7 Then
		Run($plsql)

		WinWaitActive("Oracle Logon")
		Send("+{Tab}")
		Send("sys")
		Send("{Tab}")
		Send("lis")
		Send("{Tab}")
		Send("ORCL_139")
		Send("{Tab}")
		Send("SYSDBA")
		Send("{ENTER}")

		WinWaitActive("PL/SQL Developer - sys@ORCL_139")

		;等待完成…………
		MsgBox(0,"SQL 检查","完成之后请继续!")

		If	WinExists("PL/SQL Developer - sys@ORCL_139") Then
			WinClose("PL/SQL Developer - sys@ORCL_139")
			WinWaitClose("PL/SQL Developer - sys@ORCL_139")
		EndIf
	EndIf
EndIf

;是否已经修改QC状态
$ModifiedQC = MsgBox(4,"QC 检查","是否已经修改QC状态?")
;->否:打开浏览器,进入到QC
If $ModifiedQC = 7 Then

	Send("#r")
	WinWaitActive("运行")
	Send("http://10.18.4.149:8080/qcbin/start_a.htm",1);
	Send("{Enter}")

	WinWaitActive("Mercury Quality Center 9.0 - Windows Internet Explorer")

	;等待完成…………
	MsgBox(0,"QC 检查","完成之后请继续!")

	If WinExists("Mercury Quality Center 9.0 - Windows Internet Explorer") Then
		WinClose("Mercury Quality Center 9.0 - Windows Internet Explorer")
		WinWaitClose("Mercury Quality Center 9.0 - Windows Internet Explorer")
	EndIf
EndIf

;是否已经填写变更登记?
$haveFilledChangeReport = MsgBox(4, "变更登记检查","是否已填写变更登记并签入?")
;->否;打开VSS,自动输入用户名密码,进入
If $haveFilledChangeReport = 7 Then
	Run($vss)

	WinWaitActive("Visual SourceSafe Login")
	Send("hq100545")
	Send("{Enter}")

	WinWaitActive("Visual SourceSafe Explorer -- vss60cn");

	;等待完成…………
	MsgBox(0,"变更登记检查","完成之后请继续!")

	If WinExists("Visual SourceSafe Explorer -- vss60cn") Then
		WinClose("Visual SourceSafe Explorer -- vss60cn")
		WinWaitClose("Visual SourceSafe Explorer -- vss60cn")
	EndIf

EndIf

;是否已经打印测试报告?
$havePrintedTestReport = MsgBox(4, "测试报告检查","是否已填写IT测试报告?")
;->否:打开Word
If $havePrintedTestReport = 7 Then

	Send("#r")
	WinWaitActive("运行")

	;选择当前要提交的是需求还是缺陷
	$ProgramType = MsgBox(4, "测试报告检查","请选择提交程序的类型:需求选是,Bug选否!")

	;->需求:打开RQ的测试报告
	If $ProgramType = 6 Then
		Send("WINWORD.EXE C:\IT测试报告_rq.doc", 1)
		Send("{ENTER}")
	EndIf
	;->缺陷:打开ing的测试报告
	If $ProgramType = 7 Then
		Send("WINWORD.EXE C:\IT测试报告_rq.doc", 1)
		Send("{ENTER}")
	EndIf

	;等待完成…………
	MsgBox(0,"变更登记检查","完成之后请继续!")

	If WinExists("IT测试报告_rq.doc - Microsoft Word") Then
		WinClose("IT测试报告_rq.doc - Microsoft Word")
		WinWaitClose("IT测试报告_rq.doc - Microsoft Word")
	EndIf

	If WinExists("IT测试报告_ing.doc - Microsoft Word") Then
		WinClose("IT测试报告_ing.doc - Microsoft Word")
		WinWaitClose("IT测试报告_ing.doc - Microsoft Word")
	EndIf


EndIf
;OK,可以打印测试报告并提交签字了。
MsgBox(0,"恭喜","一切OK,测试报告签字后就可以提交了!")

这样,就可以避免在发布测试环境的时候忘东忘西了,呵呵。

其实,还可以进行其他改进,比方说:

构建几个函数,让程序模块化。

使用鼠标控制事件,让自动化的程度更高。

希望大家也能够使用AotuIT这个工具,让我们日常的重复性工作的自动化程度更高。

 

posted @ 2010-07-13 09:23  侯伯薇  阅读(2625)  评论(3编辑  收藏  举报