Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QTP Test results will return exit codes
#1
Solved: 11 Years, 3 Months, 1 Week ago
Hi,

I am new to QTP and working on a critical requirement.

I am using QTP11.0 and need qtp test results in the form of codes e.g. 1 = Pass, 0 = Fail etc. ..

How is that possible ?

Thanks in advance .

~ Ashish
Reply
#2
Solved: 11 Years, 3 Months, 1 Week ago
You can make use of filesystem for excel and write the values in columns testname and status as 0 or 1 depending on whether your script passed or failed in the next line of where you write those reporter.reportevent code
Reply
#3
Solved: 11 Years, 3 Months, 1 Week ago
Thanks for reply ...

can you please elaborate the given solution as i am new to QTP... better if you provide some example...

Thanks in advance.

Reply
#4
Solved: 11 Years, 3 Months, 1 Week ago
Elaborate your requirement,where do you want to see the values 1 and 0? in the result file?
Reply
#5
Solved: 11 Years, 3 Months, 1 Week ago
The requirement is : every test case should return exit/error codes e.g. 0 for pass, 1 for fail, 2 for stopped in the middle etc.

Test results displays in Run Results Viewer window in text i.e. Passed, Failed, Done and Warning but as per our requirement we need in numeric i.e. 0, 1, 3 and 3.

It would also fine if gets results in the form of codes in log/text file.

However i am also running tests from command prompt via vb script and after end of test a log file is generating with test status (Passed/Failed/Done/Warning) but we need in codes only.

Here is the code for getting the test status :
WScript.StdOut.Write "Test status: " + qtTest.LastRunResults.Status + vbCr

Hope you understand the issue ...

Thanks,
Ashish
Reply
#6
Solved: 11 Years, 3 Months, 1 Week ago
Possible Values of LastRunResults Are

Passed--The most recent run passed.
Failed--The most recent run failed.
Warning--The most recent run returned a warning.
Running--The test or component is currently running.
Stopped--The current run was stopped.
Paused--The current run is paused.
Not applicable--There are no run results for this test or component.

So why can't you use a select case with these values and write corresponding numeric values to the log.

Some dummy code here.

assuming you have an excel file with first column as "TestName", 2nd col as "status"

Code:
set fso=createobject("excel.application")
Set wb=fso.workbooks.open("D:\Documents and Settings\admin\Desktop\a.xls")
Set sh=wb.worksheets(1)

'i is iteration value in your loop
sh.cells(i,1)=environment("TestName")
retValue=qtTest.LastRunResults.Status

Select case retValue
case "Passed":sh.cells(i,2)=1
case "Failed":sh.cells(i,2)=0.
.
.
so on

End select

wb.save

wb.close
Set sh=nothing
Set wb=nothing
Set fso=nothing
Reply
#7
Solved: 11 Years, 3 Months, 1 Week ago
I have implemented above code but I am getting "Type mismatch: 'environment'" error on code line :

Code:
sh.cells(i,1).Value = environment("TestName")

I have created one excel file and put TestName in first row and first column.
Reply
#8
Solved: 11 Years, 3 Months, 1 Week ago
i is the loop variable, if you have only one test replace i with 1
otherwise if you have many tests,use a loop with loop counter i
Reply
#9
Solved: 11 Years, 3 Months, 1 Week ago
Now i am not using loop but still getting "Type mismatch: 'environment'" error. I am pasting the entire code. please check.

Code:
Dim qtApp 'As QuickTest.Application ' Declare the Application object variable
Dim qtTest 'As QuickTest.Test ' Declare a Test object variable
Dim qtResultsOpt 'As QuickTest.RunResultsOptions ' Declare a Run Results Options object variable

Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object
qtApp.Launch ' Start QuickTest
qtApp.Visible = False ' Make the QuickTest application visible

qtApp.Open "D:\PrototypeTestCases\QTPProjects\Demo\App1", True 'Open the test in read-only mode

'set run settings for the test
Set qtTest = qtApp.Test
qtTest.Run

set fso=createobject("excel.application")
Set wb=fso.workbooks.open("D:\PrototypeTestCases\QTPProjects\Demo\App6\ResultCodes.xls")
Set sh=wb.worksheets(1)

'i is iteration value in your loop
sh.cells(1,1)=environment("TestName")
retValue=qtTest.LastRunResults.Status

Select case retValue
case "Passed":sh.cells(1,2)=1
case "Failed":sh.cells(2,2)=0.
'.
'.
'so on
End select

wb.save

wb.close
Set sh=nothing
Set wb=nothing
Set fso=nothing

WScript.StdOut.Write "Test status: " + qtTest.LastRunResults.Status + vbCr 'Check the results of the test run
qtTest.Close 'Close the test
qtApp.Quit 'Close the QTP'
Reply
#10
Solved: 11 Years, 3 Months, 1 Week ago
Code:
sh.cells(1,1)=qtTest .Environment("TestName")
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Code to run all QTP scripts and see all results Pkapoor 11 17,742 08-15-2017, 02:58 AM
Last Post: Ravi
  To send the QTP Results to mail using Thunderbird Naresh 0 2,383 04-03-2015, 03:19 PM
Last Post: Naresh
  Error while opening test run results vkalyankar 3 4,270 11-12-2014, 09:49 AM
Last Post: vinod123
  Function return value is not passed during the 3rd iteration premanand1979 0 2,240 10-16-2014, 09:40 PM
Last Post: premanand1979
  How to send QTP status results to mobile Naresh 0 3,006 09-02-2014, 03:50 PM
Last Post: Naresh

Forum Jump:


Users browsing this thread: 1 Guest(s)