How to rerun failed test cases in maven project

2,071 views
Skip to first unread message

bachkor muqthiyar

unread,
Jan 5, 2017, 9:16:30 AM1/5/17
to Selenium Users
Hi,

Could anyone tell me how to rerun the failed test cases using RetryListener in Maven project.
If possible please share the sample code along with pom.xml file.

Thanks in advance.

Rahul Rana

unread,
Jan 5, 2017, 9:53:49 AM1/5/17
to seleniu...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/6794ed05-f634-43c0-80fe-665832883d42%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Thanks & Regards,
Rahul Rana
Phone no: 9821923007

bachkor muqthiyar

unread,
Jan 5, 2017, 11:30:55 AM1/5/17
to Selenium Users
Hi Rahul,

Thanks for your quick response.
I have tried the same in TestNG class and its working fine.

I want to know, how to implement in maven project and what changes need to do in pom.xml file.

thanks

Rahul Rana

unread,
Jan 5, 2017, 11:36:54 AM1/5/17
to seleniu...@googlegroups.com
add the files to your listener package and add those those dependencies in testng.xml

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Capture1.PNG
Capture2.PNG

bachkor muqthiyar

unread,
Jan 5, 2017, 12:09:02 PM1/5/17
to Selenium Users
Hi Rahul,

I have tried the same, but am able to run the test cases as usual.

But am not able to rerun the failed cases, Could you please let me know what went wrong in my pom.xml file.

Attached the pom.xml and testng.xml file for reference.

thanks

On Thursday, 5 January 2017 19:46:30 UTC+5:30, bachkor muqthiyar wrote:
pom.xml
testng.xml

⇜Krishnan Mahadevan⇝

unread,
Jan 5, 2017, 9:40:13 PM1/5/17
to Selenium Users
Are you sure those attachments are xmls ? They dont have any content in them except for some garbled information. 
I would suggest that you post the contents on gist.github.com and then share a link of it instead.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.

bachkor muqthiyar

unread,
Jan 6, 2017, 7:16:21 AM1/6/17
to Selenium Users
Hi Krishna,

Please find the below pom.xml and TestNG.xml files.


Thanks..


On Thursday, 5 January 2017 19:46:30 UTC+5:30, bachkor muqthiyar wrote:

⇜Krishnan Mahadevan⇝

unread,
Jan 6, 2017, 11:27:58 PM1/6/17
to Selenium Users
Here's a cleaned up pom file that should work for you [ PS : I have bumped your JDK version to 1.8 since 1.6 is deprecated ]

<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.retry</groupId>
    <artifactId>MavenRetryLogic</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <properties>
        <basedir>src/test/resources</basedir>
        <jdk>1.8</jdk>
        <suite>testng.xml</suite>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>2.53.0</version>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.10</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${jdk}</source>
                    <target>${jdk}</target>
                </configuration>
                <version>3.0</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19.1</version>
                <configuration>
                    <suiteXmlFiles>
                        <suiteXmlFile>${basedir}/${suite}</suiteXmlFile>
                    </suiteXmlFiles>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>



Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.

bachkor muqthiyar

unread,
Jan 9, 2017, 9:46:37 AM1/9/17
to Selenium Users
Thanks Krishnan,

Finally, am able to rerun the failed tests successfully.

Here, i have below problems:
Its counting the failed test cases count as well in the report. Could you please let me know how to resolve this issue.
for ex: I have total 3 cases, out of 2 cases got passed and 1 case got failed. So am trying to run the failed case 2 more times and its running successfully.
But am seeing in the reports as 
Test run: 5, Failures: 1, Errors: 0, Skipped:2
Attached the screenshot for reference.

Thanks in advance.


On Thursday, 5 January 2017 19:46:30 UTC+5:30, bachkor muqthiyar wrote:
result.png

bachkor muqthiyar

unread,
Jan 9, 2017, 9:48:37 AM1/9/17
to Selenium Users
Hi, 
And am using the attached code to rerun the failed cases.

Thanks,


On Thursday, 5 January 2017 19:46:30 UTC+5:30, bachkor muqthiyar wrote:
rerunLogic.txt

Soumya Hakki

unread,
May 18, 2017, 7:57:09 AM5/18/17
to Selenium Users
Hi,

I have problem in rerunning the failed tests, when test fails it is going to retrylistener, but i couldn't see the test runs once again after sometime it gives result as "Tests run: 2, Failures: 1, Errors: 0, Skipped: 1" (When test fails i gave it rerun 1 more time) , the test is being skipped but not retrying to run once again. Please help me out with this. Thank you.

Thanks & Regards,
Soumya

On Friday, January 6, 2017 at 2:40:13 AM UTC, Krishnan wrote:
Are you sure those attachments are xmls ? They dont have any content in them except for some garbled information. 
I would suggest that you post the contents on gist.github.com and then share a link of it instead.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

On Thu, Jan 5, 2017 at 10:39 PM, bachkor muqthiyar <hadi.mu...@gmail.com> wrote:
Hi Rahul,

I have tried the same, but am able to run the test cases as usual.

But am not able to rerun the failed cases, Could you please let me know what went wrong in my pom.xml file.

Attached the pom.xml and testng.xml file for reference.

thanks

On Thursday, 5 January 2017 19:46:30 UTC+5:30, bachkor muqthiyar wrote:
Hi,

Could anyone tell me how to rerun the failed test cases using RetryListener in Maven project.
If possible please share the sample code along with pom.xml file.

Thanks in advance.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.

Krishnan Mahadevan

unread,
May 18, 2017, 7:59:17 AM5/18/17
to seleniu...@googlegroups.com

Soumya,

I would suggest that you please create a sample that can be executed to reproduce your problem and then post your query to testng-users testng...@googlegroups.com mailer list instead of here since your question seems to be related to TestNG and not Selenium (This forum is intended only for Selenium related queries)

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/

 

Soumya Hakki

unread,
May 18, 2017, 8:49:31 AM5/18/17
to Selenium Users
I followed the above mail replies to rerun failed tests in maven project, so I thought it relates to here and I posted. 

To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.

Soumya Hakki

unread,
May 18, 2017, 9:09:08 AM5/18/17
to Selenium Users
Hi bachkor muqthiyar,

For you also it is displayed skipped : 2, for you are the failed seleniumtests running?? can you see that running, For me test are not running but the result is like skipped only. Will you please help me out with this.

Regards,
Soumya 

Sele_A

unread,
Aug 31, 2017, 5:00:00 AM8/31/17
to Selenium Users
Hi All,

I am working on maven project with junit testcases . I want to re-run my failed testcases only.
Could you please guide which dependencies I need to add in my pom.xml file.

Note : I am not using testng.

Thanks & Regards,

⇜Krishnan Mahadevan⇝

unread,
Aug 31, 2017, 6:51:05 AM8/31/17
to Selenium Users
Amandeep,

Please post this query on a JUnit related forum. This forum is specifically meant only for Selenium/WebDriver queries. Please help keep this forum relevant.

Thanks in advance for your understanding and co-operation!

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages