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 2014


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

Re: [QF-Test] Re-run failed test cases


  • Subject: Re: [QF-Test] Re-run failed test cases
  • From: "Robert Lahmer, QFS support" <support@?.de>
  • Date: Wed, 21 May 2014 16:42:40 +0200


Hello Nouran,

at the moment, there is no built-in mechanism to re-run failed test-cases.
You'll need to create your own solution which might look as shown below.


1.) First create a TestRunListener which tracks the failing test-cases:


from de.qfs.apps.qftest.extensions.qftest import TestRunListener
from de.qfs.apps.qftest.shared.extensions import RunContext
import qfcommon
import os

rc = qfcommon.globalDict['__rc']

class RetryTracer(TestRunListener):
   def __init__(self, fileName):
       self._fileName = fileName
       self._f = None

   def nodeEntered(self, event):
       pass

   def nodeExited(self, event):
       pass

   def problemOccurred(self, event):
       if event.getState() >= 3:
           # Exception occured
           tc = rc.lookup("qftest", "testcase.qname")
           if not self._f:
               self._f = open(self._fileName, "w")
           self._f.write(tc + "\n")

   def runStarted(self, event):
       pass

   def runStopped(self, event):
       if self._f:
           self._f.close()
       self._f = None

global retryTracer

try:
   RunContext.removeGlobalTestRunListener(retryTracer)
except:
   pass

retryTracer = RetryTracer(os.path.join(os.getenv("TMP"), "failedTCs.txt"))
RunContext.addGlobalTestRunListener(retryTracer)


Save the above code as retryListener.py.



2.) Install the TestRunListener, run the test and get the retry list when
finished. The following .bat file shows how this can be done:


@echo off
setlocal enabledelayedexpansion

set suite=c:\mysuites\mysuite.qft
set qfdir=c:\programs\qftest\qftest-3.5.6
set logdir=c:\mylogs

set retry=%TMP%\failedTCs.txt

copy retryListener.py %qfdir%\..\jython >nul
del %retry% >nul 2>&1
pushd %qfdir%\bin
qftestc -batch -jythonrun "import retryListener" -runlog %logdir%\+b
%suite%

if not exist %retry% (
   echo No test-cases to run again.
   goto end
)

echo retrying ...
for /f "delims=" %%x in (%retry%) do (
   set tests=!tests! -test "%%x"
)
qftestc -batch -runlog %logdir%\retry_+b %tests% %suite%

:end
popd
echo done.


Adapt the variables 'suite', 'qfdir' and 'logdir' accordingly and then run
the .bat file: Every test-case that failed with an exception is stored in
the file

 %TMP%\failedTCs.txt

and will run once again afterwards (do not change the path or if so, adapt
the .py file as well).


By the way, please do not send a question to "qftest-list" and "qftest" at
the same time. You may either address the QF-Test mailing list (in case of
questions of public interest) or ask for support through QFS developers (in
case you have a valid maintenance contract).


Best regards,
   Robert




--On Dienstag, Mai 20, 2014 12:28:57 +0000 "Halawa, Nouran"
<Nouran_Halawa@?.com> wrote:

Hi all,

We need a way to re-run failed test cases only reported in the run log.
Is there a way to do this automatically form QFS side?

Best Regards,
Nouran Halawa




--
_______________________________________________________________

Get the most out of QF-Test - Support directly from the authors
* Training & consulting: www.qfs.de/en/qftest/training.html
* Phone & email support: www.qfs.de/en/qftest/support.html
_______________________________________________________________

Robert Lahmer
Development & Support

E: support@?.de
T: +49 (0)8171 38648-20
F: +49 (0)8171 38648-16

Quality First Software GmbH | www.qfs.de
Tulpenstr. 41 | 82538 Geretsried | Germany
GF Gregor Schmid, Karlheinz Kellerer
HRB München 140833