2017 up to now  | 2016 | 2015 | 2014 | 2013 | 2012 | 2011 | 2010 | 2009 | 2008 | 2007

(older archive entries before 2007 are not shown here, but included in the onsite-search)

Mailing List - Entries of 2012


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[QF-Test] Quality Center integration


  • Subject: [QF-Test] Quality Center integration
  • From: "Hunt,Chuck" <CHUNT1@?.COM>
  • Date: Fri, 28 Sep 2012 17:34:30 +0000

Hello,

 

I’m trying to get execute my QF-Test test cases from Quality Center.  It runs, but executes all the test sets.  I would like to execute only 1 particular test case.  Attached is the Test Script from QC and the QF-Test execution script.

 

Chuck Hunt

Technology Architect, CTS Solutions 

chuck.hunt@?.com | 816-201-2414 direct | 816-269-9037 mobile

www.cerner.com

Description: cern

 


CONFIDENTIALITY NOTICE This message and any included attachments are from Cerner Corporation and are intended only for the addressee. The information contained in this message is confidential and may constitute inside or non-public information under international, federal, or state securities laws. Unauthorized forwarding, printing, copying, distribution, or use of such information is strictly prohibited and may be unlawful. If you are not the addressee, please promptly delete this message and notify the sender of the delivery error by e-mail or you may call Cerner's corporate offices in Kansas City, Missouri, U.S.A at (+1) (816)221-1024.
' QF-Test test case [QF-Test Template]
' Created by Quality First Software GmbH, www.qfs.de
' For questions, please contact: qfs@xxxxxx
' ====================================================

' ----------------------------------------------------
' Main Test Function
' Debug - Boolean. Equals to false if running in [Test Mode] : reporting to Quality Center
' CurrentTestSet - [OTA COM Library].TestSet.
' CurrentTest - [OTA COM Library].TSTest.
' CurrentRun - [OTA COM Library].Run.
' ----------------------------------------------------
Sub Test_Main(Debug, CurrentTestSet, CurrentTest, 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

  ' clear output window
  TDOutput.Clear

  ' Test case specific variables.
  ' NOTE: Project specific variables should be defined in the external module.

  ' The path to the project specific VBS module. Please copy the template
  ' from the QF-Test directory to a project specific location.
  'pathToModule = "<LOCATION>\\qualitycenter\\qcModule.vbs"
  pathToModule = "C:\\Program Files\\qfs\\qcIntegrateScript2.vbs"

  ' Another way could be to fetch the path from an environment variable, like:
  ' var WshShell = WScript.CreateObject("WScript.Shell");
  ' var WshSysEnv = WshShell.Environment("USER");
  ' pathToModule = WshSysEnv(QFTESTPATH);

  ' The path to single test-case, if this variable is set to
  ' empty the whole test-suite will be executed.
  ' testCase = "CarConfigurator Demo.Options.Modify vehicle"
'  testCase = "CAM_R - CAM Alarm Details"
  testCase = "CAM_R - CAM filter settings.CAM_R - CAM filter settings"
  ' The path of the test-suite.
  ' If you run the test remotely, the file must be accessible on the test-system.
  'testSuiteFile = "c:\\Program Files\\qfs\\qftest\\qftest-3.4.6\\demo\\carconfig\\carconfig_en.qft"
  testSuiteFile = "C:\\QFTest\\CAM\\Scripts\\CAM.qft"

  ' The path to store the run-log after the test-run.
  ' If you run the test remotely, that file can be found on the test-system.
  pathToRunLog = "C:\\QFTest\\CAM\\Logs\\log.qrz"

  ' Specify, whether the run-log should be uploaded to the result of the
  ' test-run. Default is 1, which stands for uploading. 0 stands for don't upload.
  'uploadResult = 0

  ' The run-mode of QF-Test "-batch" or "-batch -calldaemon". The default is set
  ' to "-batch".
  ''runMode = "-batch -runlog C:\\01_Team\\DemoResult.qrz"
  runMode = "-batch -report"

  ' The additional options for the test-run, e.g. '-J-mX512m' to increase the memory
  ' or '-variable varName=varValue' to set variabes. The default is set to none.
  ''runOptions = "-runlog = c:\\01_Team\\WebTestResult1.qrz"
  runOptions = "C:\\QFTest\\CAM\\Logs\\Report"

  ' The timeout in milliseconds, default is infinite.
  'timeout = 10 * 60 * 1000

  ' The path to QF-Test executable, default is the installed qftest.exe.
  ' If you run the test remotely, that file must be accessible on the test-system.
  'pathToQftest = "qftest.exe"

   ' Load external function for launching QF-Test.
   ExecuteGlobal CreateObject("Scripting.FileSystemObject"). _
       OpenTextFile(pathToModule).ReadAll

   ' Function call of external QF-Test module.
   status = executeQFTest (CurrentRun, CStr(testCase), CStr(testSuiteFile), _
      CStr(pathToRunLog), CStr(timeout), CStr(uploadResult), _
        CStr(pathToQftest), CStr(runOptions), cStr(runMode))

   TDOutput.Print "Status of the test: " & CStr(status)

   ' Set the result.
   ' status = 0 stands for successfull run.
   ' status = 1 stands for run with warnings.
   ' status = 2 stands for run with errors.
   ' status = 3 stands for run with exceptions.
   ' All other values stand for errors launching QF-Test.
   If status = 0 or status = 1 Then
      CurrentRun.Status = "Passed"
      CurrentTest.Status = "Passed"
   Else
      CurrentRun.Status = "Failed"
      CurrentTest.Status = "Failed"
   End If

  ' handle run-time errors, standard handling of VAPI-XP scripts.
  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"
      CurrentTest.Status = "Failed"
    End If
  End If
End Sub
'=========================================================================================
' Execute QF-Test using the given options and perform upload of the run-log to the CurrenRun.
'
' testrun	 : The Testrun object.
' test	         : The test-case or test-set.
' suite          : The path to the test-suite file.
' runLogFile     : Optional name of the run-log.
' timeout	 : Optional timeout of test-execution.
' uploadResult   : Optional 1 for uploading the run-log, 0 for not uploading the run-log.
' qftestExe	 : Optional path to qftest-executable.
' runOptions     : Optional runOptions for qftest-run, e.g. "-report.warnings".
' runMode	 : Optional runMode, e.g. "-batch" or "-batch -calldaemon".
'=========================================================================================
  
Public Function executeQFTest (ByRef testrun, ByRef test, ByRef suite, ByRef runLogFile, ByRef timeout, ByRef uploadResult, ByRef qftestExe, ByRef runOptions, ByRef runMode )

  cmdString = ""

  '==================================================================================
  ' Default Options

  defaultRunMode = "-batch"
  defaultRunOptions = ""
  defaultRunLogFile = "" 
  qftestCall = "qftest.exe"
  thisTimeout = -1
  defaultUploadResult = 1

  '==================================================================================
  ' Evaluate given parameters

  If runMode <> "" Then
    cmdString = runMode
  Else
    cmdString = defaultRunMode 
    runMode = defaultRunMode
  End If

  If runOptions <> "" Then
    cmdString = cmdString & " " & runOptions
  Else
    cmdString = cmdString & " " & defaultRunOptions
  End If

  If runLogFile <> "" Then
    cmdString = cmdString & " -runlog """ & runLogFile & """" 
  Else
    cmdString = cmdString & " -runlog """ & defaultRunLogFile & """"
  End If

  If test <> "" and runMode = "-batch" Then
    cmdString = cmdString & " -test """ & test  & """"
  End If

  If suite <> "" Then
    cmdString = cmdString & " """ & suite & """"
    If test <> "" and InStr(runMode, "-calldaemon") > 0 Then
      cmdString = cmdString & "#""" & test & """"
    End If
  End If

  If qftestExe <> "" Then
    qftestCall = qftestExe
  End If

  If timeout <> "" Then
    thisTimeout = cInt(timeout)
  End If

  '==================================================================================
  ' Launch QF-Test with the given parameters

  TDOutput.Print "Launch -> " & qftestCall & " " & cmdString

  Dim status
  status = XTools.run (qftestCall, cmdString , thisTimeout, FALSE)  

  TDOutput.Print "... QF-Test terminated with " & status & "."  
  
  '==================================================================================
  ' Uploading the run-log.

  If uploadResult <> "" Then
   If uploadResult = 1 Then
'      uploadStatus = doUploadRunLog (testrun, runLogFile)
'      uploadStatus = doUploadReport (testrun, runOptions)
		zipfolder()
      uploadStatus = doUploadReport (testrun,"C:\QFTest\CAM\Logs\Report\report.html" )
   End If
  Else:
    If defaultUploadResult = 1 Then
'      uploadStatus = doUploadRunLog (testrun, runLogFile)
'      uploadStatus = doUploadReport (testrun, runOptions)
      uploadStatus = doUploadReport (testrun,"C:\QFTest\CAM\Logs\Report\report.html" )
    End If
  End If

  '==================================================================================
  ' Handle run-time errors.

  If Err.Number <> 0 Then
    TDOutput.Print "Run-time error [" & Err.Number & "] : " & Err.Description
  End If

  TDOutput.Print "Codes --> Tests: " & status

  executeQFTest = status
End Function


'=========================================================================================
' Upload of the run-log file.
' testrun: The CurrentRun object
' runLogFile: The file name of the run-log to be uploaded.
'=========================================================================================

Public Function doUploadRunLog (byRef testrun, byRef runLogFile)
    TDOutput.Print "Create attachments..."

    Set objFso = CreateObject("Scripting.FileSystemObject")
    content = objFso.GetFile(runLogFile)
    res = "-1"

    If content <> "" Then
      Dim attachF, attI
      Set attachF = testrun.Attachments 
      Set attI = attachF.AddItem(Null) 
      attI.FileName = runLogFile
      attI.Type = 1
      attI.Post
      set attachF = nothing
      set attI = nothing
      TDOutput.Print "... attachements created."
      res = "1"
    Else:
      TDOutput.Print "Couldn't find run-log file '" & runLogFile & "'!"
    End if  
 
    doUploadRunLog = res
End Function

'=========================================================================================
' Upload of the report file.
' testrun: The CurrentRun object
' reportFile: The file name of the report to be uploaded.
'=========================================================================================

Public Function doUploadReport (byRef testrun, byRef reportFile)
    TDOutput.Print "Create Report attachments..."

    Set objFso = CreateObject("Scripting.FileSystemObject")
    content = objFso.GetFile(reportFile)
    res = "-1"

    If content <> "" Then
      Dim attachF, attI
      Set attachF = testrun.Attachments 
      Set attI = attachF.AddItem(Null) 
      attI.FileName = reportFile
      attI.Type = 1
      attI.Post
      set attachF = nothing
      set attI = nothing
      TDOutput.Print "... Report attachements created."
      res = "1"
    Else:
      TDOutput.Print "Couldn't find report file '" & reportFile & "'!"
    End if  
 
    doUploadReport = res
End Function