Ignore a class in testng

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Ignore a class in testng

Boban Paul

There are some test classes which needs to be ignored when I run my testng suite. I tried using the @Test(enabled=false) annotation for the class and methods that needs to be ignored. But my problem is that the class that needs to be ignored extends an abstract class and this abstract class test methods are not ignored even when I have @Test(enabled=false) annotation on the base class. In Junit I could use @ignore on the base class and the test methods on the extended class would not be invoked at all. How can I replicate this behaviour in testng.

Also In my testng suite I run the test by packages and not by classes. Hence even if I try to group the class and ignore the group it is not working either. <test name="Test"> <groups> <run> <exclude name="testClass"/> </run> </groups>
<packages>

Please help - I am using Testng 6.8

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/-r1SREMZlmwJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: Ignore a class in testng

Cédric Beust ♔-2
Hi Paul,

What you are seeing is an unfortunate consequence of the way inheritance of annotations and default attributes interact with each other in TestNG, and a bug has been filed to make it work better (I don't have the id handy).

Consider:

@Test(enabled = false)
public class C {
  @Test
  public void f()
}

When TestNG resolves these annotations, it finds that the @Test on the method doesn't specify "enabled", so it assigns it its default value. The example becomes:

@Test(enabled = false)
public class C {
  @Test(enabled = true)
  public void f()
}

And now, the value defined at the method level overrides the one specified on the class.

The fix would involve using an enum instead of a boolean (ENABLED, DISABLED, INHERITED, which would be the default), but this would break backward compatibility, so I would need to introduce a new annotation for this (e.g. "runStatus" or something like that), and your example would become

@Test(runStatus = DISABLED)
public class C {
  @Test
  public void f()
}

Does this make sense?




-- 
Cédric



On Thu, Dec 20, 2012 at 11:19 AM, Boban Paul <[hidden email]> wrote:

There are some test classes which needs to be ignored when I run my testng suite. I tried using the @Test(enabled=false) annotation for the class and methods that needs to be ignored. But my problem is that the class that needs to be ignored extends an abstract class and this abstract class test methods are not ignored even when I have @Test(enabled=false) annotation on the base class. In Junit I could use @ignore on the base class and the test methods on the extended class would not be invoked at all. How can I replicate this behaviour in testng.

Also In my testng suite I run the test by packages and not by classes. Hence even if I try to group the class and ignore the group it is not working either. <test name="Test"> <groups> <run> <exclude name="testClass"/> </run> </groups>
<packages>

Please help - I am using Testng 6.8

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/-r1SREMZlmwJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: Ignore a class in testng

Boban Paul
In reply to this post by Boban Paul
Thanks Cédric for clarifying. I will wait for the fix to go in :)


On Thursday, December 20, 2012 11:19:10 AM UTC-8, Boban Paul wrote:

There are some test classes which needs to be ignored when I run my testng suite. I tried using the @Test(enabled=false) annotation for the class and methods that needs to be ignored. But my problem is that the class that needs to be ignored extends an abstract class and this abstract class test methods are not ignored even when I have @Test(enabled=false) annotation on the base class. In Junit I could use @ignore on the base class and the test methods on the extended class would not be invoked at all. How can I replicate this behaviour in testng.

Also In my testng suite I run the test by packages and not by classes. Hence even if I try to group the class and ignore the group it is not working either. <test name="Test"> <groups> <run> <exclude name="testClass"/> </run> </groups>
<packages>

Please help - I am using Testng 6.8

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/WF8f2JA6uZgJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: Ignore a class in testng

Cédric Beust ♔-2
In reply to this post by Cédric Beust ♔-2
Actually, I came up with a better solution: adding a new attribute specifically for this scenario:

@Test(enabledClass = false)
public class C {
  @Test
  public void f()
}

This solves all the inheritance/default value problems. Obviously, this attribute would have no effect if used on a @Test annotation that's on a method.



-- 
Cédric



On Thu, Dec 20, 2012 at 11:34 AM, Cédric Beust ♔ <[hidden email]> wrote:
Hi Paul,

What you are seeing is an unfortunate consequence of the way inheritance of annotations and default attributes interact with each other in TestNG, and a bug has been filed to make it work better (I don't have the id handy).

Consider:

@Test(enabled = false)
public class C {
  @Test
  public void f()
}

When TestNG resolves these annotations, it finds that the @Test on the method doesn't specify "enabled", so it assigns it its default value. The example becomes:

@Test(enabled = false)
public class C {
  @Test(enabled = true)
  public void f()
}

And now, the value defined at the method level overrides the one specified on the class.

The fix would involve using an enum instead of a boolean (ENABLED, DISABLED, INHERITED, which would be the default), but this would break backward compatibility, so I would need to introduce a new annotation for this (e.g. "runStatus" or something like that), and your example would become

@Test(runStatus = DISABLED)
public class C {
  @Test
  public void f()
}

Does this make sense?




-- 
Cédric



On Thu, Dec 20, 2012 at 11:19 AM, Boban Paul <[hidden email]> wrote:

There are some test classes which needs to be ignored when I run my testng suite. I tried using the @Test(enabled=false) annotation for the class and methods that needs to be ignored. But my problem is that the class that needs to be ignored extends an abstract class and this abstract class test methods are not ignored even when I have @Test(enabled=false) annotation on the base class. In Junit I could use @ignore on the base class and the test methods on the extended class would not be invoked at all. How can I replicate this behaviour in testng.

Also In my testng suite I run the test by packages and not by classes. Hence even if I try to group the class and ignore the group it is not working either. <test name="Test"> <groups> <run> <exclude name="testClass"/> </run> </groups>
<packages>

Please help - I am using Testng 6.8

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/-r1SREMZlmwJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.


--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: Ignore a class in testng

⇜Krishnan Mahadevan⇝
Cedric,
Doesnt this introduce the same confusion that enabled attribute has especially when someone wants to just disable the child classes?
I liked the enum solution you mentioned earlier :)


On Friday, December 21, 2012, Cédric Beust ♔ wrote:
Actually, I came up with a better solution: adding a new attribute specifically for this scenario:

@Test(enabledClass = false)
public class C {
  @Test
  public void f()
}

This solves all the inheritance/default value problems. Obviously, this attribute would have no effect if used on a @Test annotation that's on a method.



-- 
Cédric



On Thu, Dec 20, 2012 at 11:34 AM, Cédric Beust ♔ <<a href="javascript:_e({}, &#39;cvml&#39;, &#39;cedric@beust.com&#39;);" target="_blank">cedric@...> wrote:
Hi Paul,

What you are seeing is an unfortunate consequence of the way inheritance of annotations and default attributes interact with each other in TestNG, and a bug has been filed to make it work better (I don't have the id handy).

Consider:

@Test(enabled = false)
public class C {
  @Test
  public void f()
}

When TestNG resolves these annotations, it finds that the @Test on the method doesn't specify "enabled", so it assigns it its default value. The example becomes:

@Test(enabled = false)
public class C {
  @Test(enabled = true)
  public void f()
}

And now, the value defined at the method level overrides the one specified on the class.

The fix would involve using an enum instead of a boolean (ENABLED, DISABLED, INHERITED, which would be the default), but this would break backward compatibility, so I would need to introduce a new annotation for this (e.g. "runStatus" or something like that), and your example would become

@Test(runStatus = DISABLED)
public class C {
  @Test
  public void f()
}

Does this make sense?




-- 
Cédric



On Thu, Dec 20, 2012 at 11:19 AM, Boban Paul <<a href="javascript:_e({}, &#39;cvml&#39;, &#39;bobanpaulp@gmail.com&#39;);" target="_blank">bobanpaulp@...> wrote:

There are some test classes which needs to be ignored when I run my testng suite. I tried using the @Test(enabled=false) annotation for the class and methods that needs to be ignored. But my problem is that the class that needs to be ignored extends an abstract class and this abstract class test methods are not ignored even when I have @Test(enabled=false) annotation on the base class. In Junit I could use @ignore on the base class and the test methods on the extended class would not be invoked at all. How can I replicate this behaviour in testng.

Also In my testng suite I run the test by packages and not by classes. Hence even if I try to group the class and ignore the group it is not working either. <test name="Test"> <groups> <run> <exclude name="testClass"/> </run> </groups>
<packages>

Please help - I am using Testng 6.8

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/-r1SREMZlmwJ.
To post to this group, send email to <a href="javascript:_e({}, &#39;cvml&#39;, &#39;testng-users@googlegroups.com&#39;);" target="_blank">testng-users@....
To unsubscribe from this group, send email to <a href="javascript:_e({}, &#39;cvml&#39;, &#39;testng-users%2Bunsubscribe@googlegroups.com&#39;);" target="_blank">testng-users+unsubscribe@....
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.


--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to <a href="javascript:_e({}, &#39;cvml&#39;, &#39;testng-users@googlegroups.com&#39;);" target="_blank">testng-users@....
To unsubscribe from this group, send email to <a href="javascript:_e({}, &#39;cvml&#39;, &#39;testng-users%2Bunsubscribe@googlegroups.com&#39;);" target="_blank">testng-users+unsubscribe@....
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.


--
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/

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: Ignore a class in testng

Cédric Beust ♔-2
On Fri, Dec 21, 2012 at 9:03 AM, Krishnan Mahadevan <[hidden email]> wrote:
Cedric,
Doesnt this introduce the same confusion that enabled attribute has especially when someone wants to just disable the child classes?

I don't follow, can you be more specific?

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: Ignore a class in testng

⇜Krishnan Mahadevan⇝
Cedric,
Please ignore my response. I went back and re-read the thread again and it all makes sense. My apologies for not paying attention. 

On Friday, December 21, 2012, Cédric Beust ♔ wrote:
On Fri, Dec 21, 2012 at 9:03 AM, Krishnan Mahadevan <<a href="javascript:_e({}, &#39;cvml&#39;, &#39;krishnan.mahadevan1978@gmail.com&#39;);" target="_blank">krishnan.mahadevan1978@...> wrote:
Cedric,
Doesnt this introduce the same confusion that enabled attribute has especially when someone wants to just disable the child classes?

I don't follow, can you be more specific?

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to <a href="javascript:_e({}, &#39;cvml&#39;, &#39;testng-users@googlegroups.com&#39;);" target="_blank">testng-users@....
To unsubscribe from this group, send email to <a href="javascript:_e({}, &#39;cvml&#39;, &#39;testng-users%2Bunsubscribe@googlegroups.com&#39;);" target="_blank">testng-users+unsubscribe@....
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.


--
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/

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: Ignore a class in testng

Krishantha Samaraweera-2
In reply to this post by Cédric Beust ♔-2
Hi Cedric,

Is this enabledClass = false attribute is available in latest TestNG releases. I couldn't find it.

THanks,
Krishantha.
.

On Friday, December 21, 2012 10:25:23 PM UTC+5:30, Cédric Beust ♔ wrote:
Actually, I came up with a better solution: adding a new attribute specifically for this scenario:

@Test(enabledClass = false)
public class C {
  @Test
  public void f()
}

This solves all the inheritance/default value problems. Obviously, this attribute would have no effect if used on a @Test annotation that's on a method.



-- 
Cédric



On Thu, Dec 20, 2012 at 11:34 AM, Cédric Beust ♔ <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="8elMqnuIVZsJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">ced...@...> wrote:
Hi Paul,

What you are seeing is an unfortunate consequence of the way inheritance of annotations and default attributes interact with each other in TestNG, and a bug has been filed to make it work better (I don't have the id handy).

Consider:

@Test(enabled = false)
public class C {
  @Test
  public void f()
}

When TestNG resolves these annotations, it finds that the @Test on the method doesn't specify "enabled", so it assigns it its default value. The example becomes:

@Test(enabled = false)
public class C {
  @Test(enabled = true)
  public void f()
}

And now, the value defined at the method level overrides the one specified on the class.

The fix would involve using an enum instead of a boolean (ENABLED, DISABLED, INHERITED, which would be the default), but this would break backward compatibility, so I would need to introduce a new annotation for this (e.g. "runStatus" or something like that), and your example would become

@Test(runStatus = DISABLED)
public class C {
  @Test
  public void f()
}

Does this make sense?




-- 
Cédric



On Thu, Dec 20, 2012 at 11:19 AM, Boban Paul <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="8elMqnuIVZsJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">boban...@...> wrote:

There are some test classes which needs to be ignored when I run my testng suite. I tried using the @Test(enabled=false) annotation for the class and methods that needs to be ignored. But my problem is that the class that needs to be ignored extends an abstract class and this abstract class test methods are not ignored even when I have @Test(enabled=false) annotation on the base class. In Junit I could use @ignore on the base class and the test methods on the extended class would not be invoked at all. How can I replicate this behaviour in testng.

Also In my testng suite I run the test by packages and not by classes. Hence even if I try to group the class and ignore the group it is not working either. <test name="Test"> <groups> <run> <exclude name="testClass"/> </run> </groups>
<packages>

Please help - I am using Testng 6.8

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit <a href="https://groups.google.com/d/msg/testng-users/-/-r1SREMZlmwJ" target="_blank" onmousedown="this.href='https://groups.google.com/d/msg/testng-users/-/-r1SREMZlmwJ';return true;" onclick="this.href='https://groups.google.com/d/msg/testng-users/-/-r1SREMZlmwJ';return true;">https://groups.google.com/d/msg/testng-users/-/-r1SREMZlmwJ.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="8elMqnuIVZsJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">testng...@....
To unsubscribe from this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="8elMqnuIVZsJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">testng-users...@googlegroups.com.
For more options, visit this group at <a href="http://groups.google.com/group/testng-users?hl=en" target="_blank" onmousedown="this.href='http://groups.google.com/group/testng-users?hl\75en';return true;" onclick="this.href='http://groups.google.com/group/testng-users?hl\75en';return true;">http://groups.google.com/group/testng-users?hl=en.


--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Ignore a class in testng

Dinesh Srinivasan-2

yes. I am also not able to find it. I am using version 6.8.

On Tuesday, June 24, 2014 8:12:56 PM UTC+5:30, Krishantha Samaraweera wrote:
Hi Cedric,

Is this enabledClass = false attribute is available in latest TestNG releases. I couldn't find it.

THanks,
Krishantha.
.

On Friday, December 21, 2012 10:25:23 PM UTC+5:30, Cédric Beust ♔ wrote:
Actually, I came up with a better solution: adding a new attribute specifically for this scenario:

@Test(enabledClass = false)
public class C {
  @Test
  public void f()
}

This solves all the inheritance/default value problems. Obviously, this attribute would have no effect if used on a @Test annotation that's on a method.



-- 
Cédric



On Thu, Dec 20, 2012 at 11:34 AM, Cédric Beust ♔ <[hidden email]> wrote:
Hi Paul,

What you are seeing is an unfortunate consequence of the way inheritance of annotations and default attributes interact with each other in TestNG, and a bug has been filed to make it work better (I don't have the id handy).

Consider:

@Test(enabled = false)
public class C {
  @Test
  public void f()
}

When TestNG resolves these annotations, it finds that the @Test on the method doesn't specify "enabled", so it assigns it its default value. The example becomes:

@Test(enabled = false)
public class C {
  @Test(enabled = true)
  public void f()
}

And now, the value defined at the method level overrides the one specified on the class.

The fix would involve using an enum instead of a boolean (ENABLED, DISABLED, INHERITED, which would be the default), but this would break backward compatibility, so I would need to introduce a new annotation for this (e.g. "runStatus" or something like that), and your example would become

@Test(runStatus = DISABLED)
public class C {
  @Test
  public void f()
}

Does this make sense?




-- 
Cédric



On Thu, Dec 20, 2012 at 11:19 AM, Boban Paul <[hidden email]> wrote:

There are some test classes which needs to be ignored when I run my testng suite. I tried using the @Test(enabled=false) annotation for the class and methods that needs to be ignored. But my problem is that the class that needs to be ignored extends an abstract class and this abstract class test methods are not ignored even when I have @Test(enabled=false) annotation on the base class. In Junit I could use @ignore on the base class and the test methods on the extended class would not be invoked at all. How can I replicate this behaviour in testng.

Also In my testng suite I run the test by packages and not by classes. Hence even if I try to group the class and ignore the group it is not working either. <test name="Test"> <groups> <run> <exclude name="testClass"/> </run> </groups>
<packages>

Please help - I am using Testng 6.8

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit <a href="https://groups.google.com/d/msg/testng-users/-/-r1SREMZlmwJ" target="_blank" onmousedown="this.href='https://groups.google.com/d/msg/testng-users/-/-r1SREMZlmwJ';return true;" onclick="this.href='https://groups.google.com/d/msg/testng-users/-/-r1SREMZlmwJ';return true;">https://groups.google.com/d/msg/testng-users/-/-r1SREMZlmwJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
For more options, visit this group at <a href="http://groups.google.com/group/testng-users?hl=en" target="_blank" onmousedown="this.href='http://groups.google.com/group/testng-users?hl\75en';return true;" onclick="this.href='http://groups.google.com/group/testng-users?hl\75en';return true;">http://groups.google.com/group/testng-users?hl=en.


--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Ignore a class in testng

⇜Krishnan Mahadevan⇝
I dont think this is yet implemented in TestNG

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 Sun, Jun 29, 2014 at 1:50 PM, Dinesh Srinivasan <[hidden email]> wrote:

yes. I am also not able to find it. I am using version 6.8.


On Tuesday, June 24, 2014 8:12:56 PM UTC+5:30, Krishantha Samaraweera wrote:
Hi Cedric,

Is this enabledClass = false attribute is available in latest TestNG releases. I couldn't find it.

THanks,
Krishantha.
.

On Friday, December 21, 2012 10:25:23 PM UTC+5:30, Cédric Beust ♔ wrote:
Actually, I came up with a better solution: adding a new attribute specifically for this scenario:

@Test(enabledClass = false)
public class C {
  @Test
  public void f()
}

This solves all the inheritance/default value problems. Obviously, this attribute would have no effect if used on a @Test annotation that's on a method.



-- 
Cédric



On Thu, Dec 20, 2012 at 11:34 AM, Cédric Beust ♔ <[hidden email]> wrote:
Hi Paul,

What you are seeing is an unfortunate consequence of the way inheritance of annotations and default attributes interact with each other in TestNG, and a bug has been filed to make it work better (I don't have the id handy).

Consider:

@Test(enabled = false)
public class C {
  @Test
  public void f()
}

When TestNG resolves these annotations, it finds that the @Test on the method doesn't specify "enabled", so it assigns it its default value. The example becomes:

@Test(enabled = false)
public class C {
  @Test(enabled = true)
  public void f()
}

And now, the value defined at the method level overrides the one specified on the class.

The fix would involve using an enum instead of a boolean (ENABLED, DISABLED, INHERITED, which would be the default), but this would break backward compatibility, so I would need to introduce a new annotation for this (e.g. "runStatus" or something like that), and your example would become

@Test(runStatus = DISABLED)
public class C {
  @Test
  public void f()
}

Does this make sense?




-- 
Cédric



On Thu, Dec 20, 2012 at 11:19 AM, Boban Paul <[hidden email]> wrote:

There are some test classes which needs to be ignored when I run my testng suite. I tried using the @Test(enabled=false) annotation for the class and methods that needs to be ignored. But my problem is that the class that needs to be ignored extends an abstract class and this abstract class test methods are not ignored even when I have @Test(enabled=false) annotation on the base class. In Junit I could use @ignore on the base class and the test methods on the extended class would not be invoked at all. How can I replicate this behaviour in testng.

Also In my testng suite I run the test by packages and not by classes. Hence even if I try to group the class and ignore the group it is not working either. <test name="Test"> <groups> <run> <exclude name="testClass"/> </run> </groups>
<packages>

Please help - I am using Testng 6.8

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/-r1SREMZlmwJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.


--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Ignore a class in testng

Rahul Jaiswal
Hi,

Any information about whether the solution was implemented. I am using 6.11 version and i couldn't find this.

Thanks!!!

On Sunday, 29 June 2014 19:14:47 UTC+5:30, Krishnan wrote:
I dont think this is yet implemented in TestNG

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ <a href="http://wakened-cognition.blogspot.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;">http://wakened-cognition.blogspot.com/
My Technical Scribbings @ <a href="http://rationaleemotions.wordpress.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;">http://rationaleemotions.wordpress.com/


On Sun, Jun 29, 2014 at 1:50 PM, Dinesh Srinivasan <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="DvtsOx-zAPUJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dinesh.x....@...> wrote:

yes. I am also not able to find it. I am using version 6.8.


On Tuesday, June 24, 2014 8:12:56 PM UTC+5:30, Krishantha Samaraweera wrote:
Hi Cedric,

Is this enabledClass = false attribute is available in latest TestNG releases. I couldn't find it.

THanks,
Krishantha.
.

On Friday, December 21, 2012 10:25:23 PM UTC+5:30, Cédric Beust ♔ wrote:
Actually, I came up with a better solution: adding a new attribute specifically for this scenario:

@Test(enabledClass = false)
public class C {
  @Test
  public void f()
}

This solves all the inheritance/default value problems. Obviously, this attribute would have no effect if used on a @Test annotation that's on a method.



-- 
Cédric



On Thu, Dec 20, 2012 at 11:34 AM, Cédric Beust ♔ <[hidden email]> wrote:
Hi Paul,

What you are seeing is an unfortunate consequence of the way inheritance of annotations and default attributes interact with each other in TestNG, and a bug has been filed to make it work better (I don't have the id handy).

Consider:

@Test(enabled = false)
public class C {
  @Test
  public void f()
}

When TestNG resolves these annotations, it finds that the @Test on the method doesn't specify "enabled", so it assigns it its default value. The example becomes:

@Test(enabled = false)
public class C {
  @Test(enabled = true)
  public void f()
}

And now, the value defined at the method level overrides the one specified on the class.

The fix would involve using an enum instead of a boolean (ENABLED, DISABLED, INHERITED, which would be the default), but this would break backward compatibility, so I would need to introduce a new annotation for this (e.g. "runStatus" or something like that), and your example would become

@Test(runStatus = DISABLED)
public class C {
  @Test
  public void f()
}

Does this make sense?




-- 
Cédric



On Thu, Dec 20, 2012 at 11:19 AM, Boban Paul <[hidden email]> wrote:

There are some test classes which needs to be ignored when I run my testng suite. I tried using the @Test(enabled=false) annotation for the class and methods that needs to be ignored. But my problem is that the class that needs to be ignored extends an abstract class and this abstract class test methods are not ignored even when I have @Test(enabled=false) annotation on the base class. In Junit I could use @ignore on the base class and the test methods on the extended class would not be invoked at all. How can I replicate this behaviour in testng.

Also In my testng suite I run the test by packages and not by classes. Hence even if I try to group the class and ignore the group it is not working either. <test name="Test"> <groups> <run> <exclude name="testClass"/> </run> </groups>
<packages>

Please help - I am using Testng 6.8

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit <a href="https://groups.google.com/d/msg/testng-users/-/-r1SREMZlmwJ" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msg/testng-users/-/-r1SREMZlmwJ&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msg/testng-users/-/-r1SREMZlmwJ&#39;;return true;">https://groups.google.com/d/msg/testng-users/-/-r1SREMZlmwJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
For more options, visit this group at <a href="http://groups.google.com/group/testng-users?hl=en" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://groups.google.com/group/testng-users?hl\x3den&#39;;return true;" onclick="this.href=&#39;http://groups.google.com/group/testng-users?hl\x3den&#39;;return true;">http://groups.google.com/group/testng-users?hl=en.


--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="DvtsOx-zAPUJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng-users...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="DvtsOx-zAPUJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@....
Visit this group at <a href="http://groups.google.com/group/testng-users" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://groups.google.com/group/testng-users&#39;;return true;" onclick="this.href=&#39;http://groups.google.com/group/testng-users&#39;;return true;">http://groups.google.com/group/testng-users.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Ignore a class in testng

Julien Herr
Hi,

You can have a look at https://github.com/cbeust/testng/pull/861

Julien

Le lundi 31 juillet 2017 12:20:25 UTC+2, Rahul Jaiswal a écrit :
Hi,

Any information about whether the solution was implemented. I am using 6.11 version and i couldn't find this.

Thanks!!!

On Sunday, 29 June 2014 19:14:47 UTC+5:30, Krishnan wrote:
I dont think this is yet implemented in TestNG

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ <a href="http://wakened-cognition.blogspot.com/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;">http://wakened-cognition.blogspot.com/
My Technical Scribbings @ <a href="http://rationaleemotions.wordpress.com/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;">http://rationaleemotions.wordpress.com/


On Sun, Jun 29, 2014 at 1:50 PM, Dinesh Srinivasan <[hidden email]> wrote:

yes. I am also not able to find it. I am using version 6.8.


On Tuesday, June 24, 2014 8:12:56 PM UTC+5:30, Krishantha Samaraweera wrote:
Hi Cedric,

Is this enabledClass = false attribute is available in latest TestNG releases. I couldn't find it.

THanks,
Krishantha.
.

On Friday, December 21, 2012 10:25:23 PM UTC+5:30, Cédric Beust ♔ wrote:
Actually, I came up with a better solution: adding a new attribute specifically for this scenario:

@Test(enabledClass = false)
public class C {
  @Test
  public void f()
}

This solves all the inheritance/default value problems. Obviously, this attribute would have no effect if used on a @Test annotation that's on a method.



-- 
Cédric



On Thu, Dec 20, 2012 at 11:34 AM, Cédric Beust ♔ <[hidden email]> wrote:
Hi Paul,

What you are seeing is an unfortunate consequence of the way inheritance of annotations and default attributes interact with each other in TestNG, and a bug has been filed to make it work better (I don't have the id handy).

Consider:

@Test(enabled = false)
public class C {
  @Test
  public void f()
}

When TestNG resolves these annotations, it finds that the @Test on the method doesn't specify "enabled", so it assigns it its default value. The example becomes:

@Test(enabled = false)
public class C {
  @Test(enabled = true)
  public void f()
}

And now, the value defined at the method level overrides the one specified on the class.

The fix would involve using an enum instead of a boolean (ENABLED, DISABLED, INHERITED, which would be the default), but this would break backward compatibility, so I would need to introduce a new annotation for this (e.g. "runStatus" or something like that), and your example would become

@Test(runStatus = DISABLED)
public class C {
  @Test
  public void f()
}

Does this make sense?




-- 
Cédric



On Thu, Dec 20, 2012 at 11:19 AM, Boban Paul <[hidden email]> wrote:

There are some test classes which needs to be ignored when I run my testng suite. I tried using the @Test(enabled=false) annotation for the class and methods that needs to be ignored. But my problem is that the class that needs to be ignored extends an abstract class and this abstract class test methods are not ignored even when I have @Test(enabled=false) annotation on the base class. In Junit I could use @ignore on the base class and the test methods on the extended class would not be invoked at all. How can I replicate this behaviour in testng.

Also In my testng suite I run the test by packages and not by classes. Hence even if I try to group the class and ignore the group it is not working either. <test name="Test"> <groups> <run> <exclude name="testClass"/> </run> </groups>
<packages>

Please help - I am using Testng 6.8

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit <a href="https://groups.google.com/d/msg/testng-users/-/-r1SREMZlmwJ" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msg/testng-users/-/-r1SREMZlmwJ&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msg/testng-users/-/-r1SREMZlmwJ&#39;;return true;">https://groups.google.com/d/msg/testng-users/-/-r1SREMZlmwJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
For more options, visit this group at <a href="http://groups.google.com/group/testng-users?hl=en" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://groups.google.com/group/testng-users?hl\x3den&#39;;return true;" onclick="this.href=&#39;http://groups.google.com/group/testng-users?hl\x3den&#39;;return true;">http://groups.google.com/group/testng-users?hl=en.


--
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 [hidden email].
Visit this group at <a href="http://groups.google.com/group/testng-users" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://groups.google.com/group/testng-users&#39;;return true;" onclick="this.href=&#39;http://groups.google.com/group/testng-users&#39;;return true;">http://groups.google.com/group/testng-users.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.