Is there a way to set configfailurepolicy via the maven failsafe (not surefire) plugin?

249 views
Skip to first unread message

Shawn McCarthy

unread,
May 11, 2015, 12:48:31 AM5/11/15
to testng...@googlegroups.com
I can't seem to find a way to set the configfailurepolicy in the maven pom.xml file (for the maven-failsafe-plugin). Does it make sense to have this feature for failsafe? I can attempt a pull request, if other people think it would be helpful. I want this feature in case my BeforeMethod fails, the rest of the tests that use the same BeforeMethod don't get skipped.

I saw it was added to the maven-surefire-plugin here : https://jira.codehaus.org/browse/SUREFIRE-927 , but I don't think it is added to the failsafe plugin.

Thank you.

Krishnan Mahadevan

unread,
May 11, 2015, 3:20:50 AM5/11/15
to testng...@googlegroups.com
Shawn,
I have never used this plugin but can't this just be included in your suite xml file ?

I have a whackier way of doing this which doesn't involve a change to the failsafe plugin code base :) [ yes its for sure a whackier approach ]

You could perhaps leverage the filtering option that is available in Maven wherein based on a JVM argument you could flip the value based on a JVM argument perhaps.

Your suite xml file could look like below :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" configfailurepolicy="${policy}" data-provider-thread-count="20" group-by-instances="false"
parallel="methods">
<test name="Test">
<packages>
<package name="com.test.testng.*"/>
</packages>
</test>
</suite>
Your pom file's resource filtering section could look like below 

<testResources>
<testResource>
<directory>src/test/resources</directory>
<includes>
<include>configfailurepolicy.xml</include>
</includes>
<filtering>true</filtering>
</testResource>
</testResources>
Your pom's properties section could look like below :

<properties>
<policy>continue</policy>
</properties>
And you could execute your tests using a command as below 

 mvn clean resources:testResources test -DsuiteXmlFile=target/test-classes/configfailurepolicy.xml -Dpolicy=skip











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 "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To post to this group, send email to testng...@googlegroups.com.
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

Shawn McCarthy

unread,
May 13, 2015, 7:54:09 PM5/13/15
to testng...@googlegroups.com
Thank you Krishnan. I will look into your suggestions. I wanted to keep it out of the suite xml file, in case people wanted to change the thread count dynamically (without updating the code and committing it).
Reply all
Reply to author
Forward
0 new messages