www.softwaretestforum.dk Forum Index www.softwaretestforum.dk
Virtuelle netværks forum for dem som arbejder professionelt med QA og software test
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Vapi og parametre

 
Post new topic   Reply to topic    www.softwaretestforum.dk Forum Index -> Quality Center
View previous topic :: View next topic  
Author Message
Christian Nørlyng
Bruger på niveau 2
Bruger på niveau 2


Joined: 30 Aug 2008
Posts: 18
Location: København

PostPosted: Tue Feb 16, 2010 11:46 am    Post subject: Vapi og parametre Reply with quote

Er der nogen der har anvendt parametre til XP-Vapi?
Eller er der nogen der har en reference manual.
VB eller java-script er under ordnet!
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Christian Nørlyng
Bruger på niveau 2
Bruger på niveau 2


Joined: 30 Aug 2008
Posts: 18
Location: København

PostPosted: Tue Feb 16, 2010 3:10 pm    Post subject: XP-VapiScript med parametre og filbehandling Reply with quote

Vapiscript med parametre

her er et Vapi Vb script der læser 3 parametre fra et "Manuelt" teststep

Scriptet er lavet således, det kan køres i en test mode under debug. Og når det tages med i et testset, skal parametrene udfyldes

prmSuccesStr
er den søgestreng jeg leder efter i filen jeg søger i

prmTestScriptName
Er et testScript jeg afvikler

prmFileName
Filen jeg ønsker at søge efter min textstreng i

Xtools.Run kører en lille dummy consol applikation der returnerer det argument der sendes med under debug. Dette er blot til test formål



Lavede en lille tilføjelse, således der er tilføjet en Sub, der opretter en defect, hvis testen fejler

PS.
Det er ikke verdens kønneste script, men det virker! ;-)



' VapiVBScript [VBScript]
' Created by Christian Nørlyng
' PrettyGoodTesting.com
' 16-02-2010 13:04:37
' ====================================================

' ----------------------------------------------------
' Main Test Function
' Debug - Boolean. Equals to false if running in [Test Mode] : reporting to Quality Center
' CurrentTestSet - [OTA COM Library].TestSet.
' CurrentTSTest - [OTA COM Library].TSTest.
' CurrentRun - [OTA COM Library].Run.
' ----------------------------------------------------

Sub MyAddDefect(Summery)
'Get the IBugFactory Not Used in QC
'Set BugFactory = TDConnection.BugFactory

'Add a new empty bug
Set Bug = BugFactory.AddItem (Nothing)

'fill the bug with relevant parameters
Bug.Status = "New"
Bug.Summary = "AutoTest:" & Summery
' call COM method : Variant FindSimilarBugs ( [in,optional,default(10)] SimilarityRatio : Integer )
' Searches the defect summaries for similarities to this defect.
Bug.FindSimilarBugs(SimilarityRatio)

'Bug.SEVERITY = "1-Low" ' depends on the DB
Bug.Priority = "4-Very High" ' depends on the DB
Bug.AssignedTo = "Bruger" ' user that must exist in the DB's users list
Bug.DetectedBy = "Bruger" ' user that must exist in the DB's users list
'Bug.DetectedonDate = "17-02-2010" ' user that must exist in the DB's users list
Set Similarities = Bug.FindSimilarBugs(10)


Bug.Post
Bug.Mail "PGT@PrettyGoodTesting.com", "copyto@PrettyGoodTesting.com", 1, Bug.Summary, "Det er helt galt"
End Sub











Sub Test_Main(Debug, CurrentTestSet, CurrentTSTest, CurrentRun)
' *** VBScript Limitation ! ***
' "On Error Resume Next" statement suppresses run-time script errors.
' To handle run-time error in a right way, you need to put "If Err.Number <> 0 Then"
' after each line of code that can cause such a run-time error.
On Error Resume Next
' MyAddDefect
' clear output window

' Holder for the Pas Fail Criteria
Dim TestBit
TestBit = false


TDOutput.Clear

If CurrentTSTest.HasSteps Then
TDOutput.Print "Test Has Steps"

Dim prmSuccesStr, prmTestScriptName, prmFileName, strSummery
Dim runTimeOut

If Debug Then
prmTestScriptName = "C:\DummyConsole.exe"
prmSuccesStr = "SUCCESS"
prmFileName= "C:\test.txt"
runTimeOut = 10000 ' 10 sekunder
Else
Set StepParams = CurrentTSTest.Params

prmTestScriptName=StepParams.ParamValue(0)
prmSuccesStr=StepParams.ParamValue(1)
prmFileName=StepParams.ParamValue(2)

runTimeOut = 60000 ' 1 minut
End If

TDOutput.Print "Param prmSuccesStr: " & prmSuccesStr
TDOutput.Print "Param prmTestScriptName: " & prmTestScriptName
TDOutput.Print "Param prmFileName: " & prmFileName

strSummery = "prmSuccesStr: " & prmSuccesStr & " - prmTestScriptName: " & prmTestScriptName & " - prmFileName: " & prmFileName

If Not Debug Then
Xtools.Run prmTestScriptName, " rgument", runTimeOut, true
Else
Xtools.Run prmTestScriptName, " rgument", runTimeOut, true
End IF

Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim arrFileLines()
i = 0
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(prmFileName, ForReading)

Do Until objFile.AtEndOfStream
Redim Preserve arrFileLines(i)
arrFileLines(i) = objFile.ReadLine
i = i + 1
Loop

objFile.Close

For Each txtLine In arrFileLines
If InStr(txtLine,prmSuccesStr) Then
TDOutput.Print "Test SUCCESS"
TDOutput.Print "I'm done reading. Found what I was looking for!"
TestBit = true
Exit For
Else
If Not TestBit = true Then
TDOutput.Print "Test FAILED"
TDOutput.Print "Reading next line for a better result!!"
End If
End If
Next

If TestBit = true Then
TDOutput.Print "Passed"
End If

If Not Debug Then
If TestBit = true Then
CurrentRun.Status = "Passed"
CurrentTSTest.Status = "Passed"
TDOutput.Print = "Passed"
Err.Number = 0
Else
CurrentRun.Status = "Failed"
CurrentTSTest.Status = "Failed"
MyAddDefect(strSummery)
End If
End If

Else
TDOutput.Print "No Parameters"
End if

If Not Debug Then
End If
' handle run-time errors
If Err.Number <> 0 Then
TDOutput.Print "Run-time error [" & Err.Number & "] : " & Err.Description
' update execution status in "Test" mode
If Not Debug Then
CurrentRun.Status = "Failed"
CurrentTSTest.Status = "Failed"
End If
End If
End Sub
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.softwaretestforum.dk Forum Index -> Quality Center All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group