If you want automatically rerun your failed testcases after completion,then use below approach:
Note:i think you know that whenever testcase is failed in testng,it creates a "testng-failed.xml" for failed testcases.
1)if you want to rerun automatically only failed testcases then you need modify pom.xml.
2) Run time you need to change testng.xml file path to "testng-failed.xml" in pom.xml.This you can do using any script language.I have done same using batch script.
Below is the batch script for same:
setlocal enabledelayedexpansion
set INTEXTFILE=pom.xml
set OUTTEXTFILE=pom_out.txt
set SEARCHTEXT=src/main/resources/testng.xml
set REPLACETEXT=target/failsafe-reports/testng-failed.xml
set OUTPUTLINE=
call mvn integration-test
for /f "tokens=1,* delims=¶" %%A in ( '"type %INTEXTFILE%"') do (
SET string=%%A
SET modified=!string:%SEARCHTEXT%=%REPLACETEXT%!
echo !modified! >> %OUTTEXTFILE%
)
del %INTEXTFILE%
rename %OUTTEXTFILE% %INTEXTFILE%
call mvn integration-test
for /f "tokens=1,* delims=¶" %%A in ( '"type %INTEXTFILE%"') do (
SET string=%%A
SET modified=!string:%REPLACETEXT%=%SEARCHTEXT%!
echo !modified! >> %OUTTEXTFILE%
)
del %INTEXTFILE%
rename %OUTTEXTFILE% %INTEXTFILE%
3) Now start execution using above batch file.
No comments:
Post a Comment