How do I disable a subclass test?

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

How do I disable a subclass test?

Joshua Fox
How do I disable subclass tests?

My design includes a base class with
@Test methods, and subclasses without their own @Test methods. Using enabled=false on the class level does not disable the subclass as you might hope.

// A.java public abstract class A { @Test public void testMethod(){ //... hookMethod(); //... } protected abstract void hookMethod(); } // B.java @Test (enabled=false) //doesn't disable test public class B extends A { protected void hookMethod() { // implementation } }

protected abstract void hookMethod(); } // C.java @Test //runs like B public class C extends A { protected void hookMethod() { // implementation } }

--
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: How do I disable a subclass test?

Krishnan Mahadevan
Joshua,

Please check if Ignoring tests would work for you here : http://testng.org/doc/documentation-main.html#ignore-tests

You need to be on the latest released version of TestNG (6.14.3 as of today)

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 Tue, Feb 27, 2018 at 3:17 PM, Joshua Fox <[hidden email]> wrote:
How do I disable subclass tests?

My design includes a base class with
@Test methods, and subclasses without their own @Test methods. Using enabled=false on the class level does not disable the subclass as you might hope.

// A.java public abstract class A { @Test public void testMethod(){ //... hookMethod(); //... } protected abstract void hookMethod(); } // B.java @Test (enabled=false) //doesn't disable test public class B extends A { protected void hookMethod() { // implementation } }

protected abstract void hookMethod(); } // C.java @Test //runs like B public class C extends A { protected void hookMethod() { // implementation } }

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

--
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: How do I disable a subclass test?

Joshua Fox
In reply to this post by Joshua Fox
Does this allow disabling  tests on a subclass? Apparently not. See this from Cedric
https://stackoverflow.com/questions/13923801/ignore-a-class-in-testng

On Tuesday, February 27, 2018 at 11:48:46 AM UTC+2, Joshua Fox wrote:
How do I disable subclass tests?

My design includes a base class with
@Test methods, and subclasses without their own @Test methods. Using enabled=false on the class level does not disable the subclass as you might hope.

// A.java public abstract class A { @Test public void testMethod(){ //... hookMethod(); //... } protected abstract void hookMethod(); } // B.java @Test (enabled=false) //doesn't disable test public class B extends A { protected void hookMethod() { // implementation } }

protected abstract void hookMethod(); } // C.java @Test //runs like B public class C extends A { protected void hookMethod() { // implementation } }

--
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: How do I disable a subclass test?

Krishnan Mahadevan
Joshua,

I guess it does. I remember seeing unit tests that were added for checking that piece.
What happens when you try using that annotation ? 

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 Tue, Feb 27, 2018 at 8:25 PM, Joshua Fox <[hidden email]> wrote:
Does this allow disabling  tests on a subclass? Apparently not. See this from Cedric
https://stackoverflow.com/questions/13923801/ignore-a-class-in-testng

On Tuesday, February 27, 2018 at 11:48:46 AM UTC+2, Joshua Fox wrote:
How do I disable subclass tests?

My design includes a base class with
@Test methods, and subclasses without their own @Test methods. Using enabled=false on the class level does not disable the subclass as you might hope.

// A.java public abstract class A { @Test public void testMethod(){ //... hookMethod(); //... } protected abstract void hookMethod(); } // B.java @Test (enabled=false) //doesn't disable test public class B extends A { protected void hookMethod() { // implementation } }

protected abstract void hookMethod(); } // C.java @Test //runs like B public class C extends A { protected void hookMethod() { // implementation } }

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

--
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: How do I disable a subclass test?

Joshua Fox
I ran a simple test with classes A, B, C as shown, and enabled=false does NOT disable the subclass's tests.

On Tue, Feb 27, 2018 at 6:00 PM, ⇜Krishnan Mahadevan⇝ <[hidden email]> wrote:
Joshua,

I guess it does. I remember seeing unit tests that were added for checking that piece.
What happens when you try using that annotation ? 

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 Tue, Feb 27, 2018 at 8:25 PM, Joshua Fox <[hidden email]> wrote:
Does this allow disabling  tests on a subclass? Apparently not. See this from Cedric
https://stackoverflow.com/questions/13923801/ignore-a-class-in-testng

On Tuesday, February 27, 2018 at 11:48:46 AM UTC+2, Joshua Fox wrote:
How do I disable subclass tests?

My design includes a base class with
@Test methods, and subclasses without their own @Test methods. Using enabled=false on the class level does not disable the subclass as you might hope.

// A.java public abstract class A { @Test public void testMethod(){ //... hookMethod(); //... } protected abstract void hookMethod(); } // B.java @Test (enabled=false) //doesn't disable test public class B extends A { protected void hookMethod() { // implementation } }

protected abstract void hookMethod(); } // C.java @Test //runs like B public class C extends A { protected void hookMethod() { // implementation } }

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

--
You received this message because you are subscribed to a topic in the Google Groups "testng-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/testng-users/d_m7S0upJl8/unsubscribe.
To unsubscribe from this group and all its topics, 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.



--
 

JOSHUA FOX
Director, Software Architecture | Freightos



T (Israel): +972-545691165 | T (US):  +1-3123400953  
Smooth shipping.



--
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: How do I disable a subclass test?

Krishnan Mahadevan

Joshua,

You mean you tried something like this using TestNG 6.14.3 ?

 

import org.testng.annotations.Test;

@Test
public class ParentClass {

   
public void testA() {
        System.
err.println("testA()");
    }
   
public void testB() {
        System.
err.println("testB()");
    }

}

 

import org.testng.annotations.Ignore;
import org.testng.annotations.Test;

public class ChildClass extends ParentClass {
   
@Test
    @Ignore
   
public void testC() {
        System.
err.println("testC()");
    }

   
@Test
    @Ignore
   
public void testD() {
        System.
err.println("testD()");
    }
}

 

 

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/

Reply-To: <[hidden email]>
Date: Tuesday, February 27, 2018 at 9:48 PM
To: <[hidden email]>
Subject: Re: [testng-users] Re: How do I disable a subclass test?

 

 

On Tue, Feb 27, 2018 at 6:00 PM, Krishnan Mahadevan <[hidden email]> wrote:

Joshua,

 

I guess it does. I remember seeing unit tests that were added for checking that piece.

What happens when you try using that annotation ? 


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 Tue, Feb 27, 2018 at 8:25 PM, Joshua Fox <[hidden email]> wrote:

Does this allow disabling  tests on a subclass? Apparently not. See this from Cedric

https://stackoverflow.com/questions/13923801/ignore-a-class-in-testng

On Tuesday, February 27, 2018 at 11:48:46 AM UTC+2, Joshua Fox wrote:

How do I disable subclass tests?

My design includes a base class with
@Test
methods, and  subclasses without their own @Test methods. Using enabled=false on the class level does not disable the subclass as you might hope.

  // A.java

public abstract class A {

   @Test

   public void testMethod(){

     //...

     hookMethod();

     //...

   }

   protected  abstract void hookMethod();

}

 

// B.java

@Test (enabled=false) //doesn't disable test

public class B extends A {

   protected void  hookMethod() {

    // implementation

   }

}

protected  abstract void hookMethod();

}

 

// C.java

@Test //runs like B

public class C extends A {

   protected void  hookMethod() {

    // implementation

   }

}

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

 

--
You received this message because you are subscribed to a topic in the Google Groups "testng-users" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/testng-users/d_m7S0upJl8/unsubscribe.
To unsubscribe from this group and all its topics, 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.



 

--

 

 

JOSHUA FOX

Director, Software Architecture | Freightos

 

 

T (Israel): +972-545691165 | T (US):  +1-3123400953  

Smooth shipping.

 

 

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

--
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: How do I disable a subclass test?

Joshua Fox
My class setup is a little different. The subclass has no @Test methods of its own.

Thank you for the  @Ignore annotation!  I guess it new https://github.com/cbeust/testng/pull/861 and seems to do the job.


On Wed, Feb 28, 2018 at 5:43 AM, Krishnan Mahadevan <[hidden email]> wrote:

Joshua,

You mean you tried something like this using TestNG 6.14.3 ?

 

import org.testng.annotations.Test;

@Test
public class ParentClass {

   
public void testA() {
        System.
err.println("testA()");
    }
   
public void testB() {
        System.
err.println("testB()");
    }

}

 

import org.testng.annotations.Ignore;
import org.testng.annotations.Test;

public class ChildClass extends ParentClass {
   
@Test
    @Ignore
   
public void testC() {
        System.
err.println("testC()");
    }

   
@Test
    @Ignore
   
public void testD() {
        System.
err.println("testD()");
    }
}

 

 

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/

Reply-To: <[hidden email]>
Date: Tuesday, February 27, 2018 at 9:48 PM
To: <[hidden email]>
Subject: Re: [testng-users] Re: How do I disable a subclass test?

 

On Tue, Feb 27, 2018 at 6:00 PM, Krishnan Mahadevan <[hidden email]> wrote:

Joshua,

 

I guess it does. I remember seeing unit tests that were added for checking that piece.

What happens when you try using that annotation ? 


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 Tue, Feb 27, 2018 at 8:25 PM, Joshua Fox <[hidden email]> wrote:

Does this allow disabling  tests on a subclass? Apparently not. See this from Cedric

https://stackoverflow.com/questions/13923801/ignore-a-class-in-testng

On Tuesday, February 27, 2018 at 11:48:46 AM UTC+2, Joshua Fox wrote:

How do I disable subclass tests?

My design includes a base class with
@Test
methods, and  subclasses without their own @Test methods. Using enabled=false on the class level does not disable the subclass as you might hope.

  // A.java

public abstract class A {

   @Test

   public void testMethod(){

     //...

     hookMethod();

     //...

   }

   protected  abstract void hookMethod();

}

 

// B.java

@Test (enabled=false) //doesn't disable test

public class B extends A {

   protected void  hookMethod() {

    // implementation

   }

}

protected  abstract void hookMethod();

}

 

// C.java

@Test //runs like B

public class C extends A {

   protected void  hookMethod() {

    // implementation

   }

}

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

 

--
You received this message because you are subscribed to a topic in the Google Groups "testng-users" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/testng-users/d_m7S0upJl8/unsubscribe.
To unsubscribe from this group and all its topics, 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.



 

--

 

 

JOSHUA FOX

Director, Software Architecture | Freightos

 

Image removed by sender.

 

T (Israel): <a href="tel:+972%2054-569-1165" value="+972545691165" target="_blank">+972-545691165 | T (US):  +<a href="tel:(312)%20340-0953" value="+13123400953" target="_blank">1-3123400953  

Smooth shipping.

 

 

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

--
You received this message because you are subscribed to a topic in the Google Groups "testng-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/testng-users/d_m7S0upJl8/unsubscribe.
To unsubscribe from this group and all its topics, 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.



--
 

JOSHUA FOX
Director, Software Architecture | Freightos



T (Israel): +972-545691165 | T (US):  +1-3123400953  
Smooth shipping.



--
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: How do I disable a subclass test?

Joshua Fox
Unfortunately, with the following code, mvn test still runs the  test, printing ChildClassTest#hook(), whether I use either or both of Ignore and enabled=false


// ========= ParentClassTest.java =========
package pkg1;

import org.testng.annotations.Test;

public  abstract class ParentClassTest {
@Test
public void testc() throws Exception {
hook();
}

protected abstract void hook();
}


// ========= ChildClassTest.java =========
package pkg1;

import org.testng.annotations.Ignore;
import org.testng.annotations.Test;

//Neither of these annotations prevents the test from running
@Ignore
@Test(enabled=false)
public class ChildClassTest extends ParentClassTest {
@Override
protected void hook() {
System.out.println("ChildClassTest#hook()");

}
}



On Wed, Feb 28, 2018 at 11:49 AM, Joshua Fox <[hidden email]> wrote:
My class setup is a little different. The subclass has no @Test methods of its own.

Thank you for the  @Ignore annotation!  I guess it new https://github.com/cbeust/testng/pull/861 and seems to do the job.


On Wed, Feb 28, 2018 at 5:43 AM, Krishnan Mahadevan <[hidden email]> wrote:

Joshua,

You mean you tried something like this using TestNG 6.14.3 ?

 

import org.testng.annotations.Test;

@Test
public class ParentClass {

   
public void testA() {
        System.
err.println("testA()");
    }
   
public void testB() {
        System.
err.println("testB()");
    }

}

 

import org.testng.annotations.Ignore;
import org.testng.annotations.Test;

public class ChildClass extends ParentClass {
   
@Test
    @Ignore
   
public void testC() {
        System.
err.println("testC()");
    }

   
@Test
    @Ignore
   
public void testD() {
        System.
err.println("testD()");
    }
}

 

 

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/

Reply-To: <[hidden email]>
Date: Tuesday, February 27, 2018 at 9:48 PM
To: <[hidden email]>
Subject: Re: [testng-users] Re: How do I disable a subclass test?

 

On Tue, Feb 27, 2018 at 6:00 PM, Krishnan Mahadevan <[hidden email]> wrote:

Joshua,

 

I guess it does. I remember seeing unit tests that were added for checking that piece.

What happens when you try using that annotation ? 


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 Tue, Feb 27, 2018 at 8:25 PM, Joshua Fox <[hidden email]> wrote:

Does this allow disabling  tests on a subclass? Apparently not. See this from Cedric

https://stackoverflow.com/questions/13923801/ignore-a-class-in-testng

On Tuesday, February 27, 2018 at 11:48:46 AM UTC+2, Joshua Fox wrote:

How do I disable subclass tests?

My design includes a base class with
@Test
methods, and  subclasses without their own @Test methods. Using enabled=false on the class level does not disable the subclass as you might hope.

  // A.java

public abstract class A {

   @Test

   public void testMethod(){

     //...

     hookMethod();

     //...

   }

   protected  abstract void hookMethod();

}

 

// B.java

@Test (enabled=false) //doesn't disable test

public class B extends A {

   protected void  hookMethod() {

    // implementation

   }

}

protected  abstract void hookMethod();

}

 

// C.java

@Test //runs like B

public class C extends A {

   protected void  hookMethod() {

    // implementation

   }

}

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

 

--
You received this message because you are subscribed to a topic in the Google Groups "testng-users" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/testng-users/d_m7S0upJl8/unsubscribe.
To unsubscribe from this group and all its topics, 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.



 

--

 

 

JOSHUA FOX

Director, Software Architecture | Freightos

 

Image removed by sender.

 

T (Israel): <a href="tel:+972%2054-569-1165" value="+972545691165" target="_blank">+972-545691165 | T (US):  +<a href="tel:(312)%20340-0953" value="+13123400953" target="_blank">1-3123400953  

Smooth shipping.

 

 

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

--
You received this message because you are subscribed to a topic in the Google Groups "testng-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/testng-users/d_m7S0upJl8/unsubscribe.
To unsubscribe from this group and all its topics, 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.



--
 

JOSHUA FOX
Director, Software Architecture | Freightos



T (Israel): <a href="tel:+972%2054-569-1165" value="+972545691165" target="_blank">+972-545691165 | T (US):  +<a href="tel:(312)%20340-0953" value="+13123400953" target="_blank">1-3123400953  
Smooth shipping.






--
 

JOSHUA FOX
Director, Software Architecture | Freightos



T (Israel): +972-545691165 | T (US):  +1-3123400953  
Smooth shipping.



--
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: How do I disable a subclass test?

Krishnan Mahadevan

Joshua,

 

This is a bug. We need to get this fixed.

 

But with the way currently TestNG works, it may be a bit difficult.

 

You can track the discussions of this issue here : https://github.com/cbeust/testng/issues/1709

 

 

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/

From: <[hidden email]> on behalf of Joshua Fox <[hidden email]>
Reply-To: <[hidden email]>
Date: Wednesday, February 28, 2018 at 4:03 PM
To: <[hidden email]>
Subject: Re: [testng-users] Re: How do I disable a subclass test?

 

Unfortunately, with the following code, mvn test still runs the  test, printing ChildClassTest#hook(), whether I use either or both of Ignore and enabled=false

 

 

// ========= ParentClassTest.java =========

package pkg1;

 

import org.testng.annotations.Test;

 

public  abstract class ParentClassTest {

     @Test

     public void testc() throws Exception {

                hook();

     }

 

     protected abstract void hook();

}

 



// ========= ChildClassTest.java =========

package pkg1;

 

import org.testng.annotations.Ignore;

import org.testng.annotations.Test;

 

//Neither of these annotations prevents the test from running

@Ignore

@Test(enabled=false)

public class ChildClassTest extends ParentClassTest {

     @Override

     protected void hook() {

           System.out.println("ChildClassTest#hook()");

 

     }

}

 

 

 

On Wed, Feb 28, 2018 at 11:49 AM, Joshua Fox <[hidden email]> wrote:

My class setup is a little different. The subclass has no @Test methods of its own.

 

Thank you for the  @Ignore annotation!  I guess it new https://github.com/cbeust/testng/pull/861 and seems to do the job.

 

 

On Wed, Feb 28, 2018 at 5:43 AM, Krishnan Mahadevan <[hidden email]> wrote:

Joshua,

You mean you tried something like this using TestNG 6.14.3 ?

 

import org.testng.annotations.Test;

@Test
public class ParentClass {

   
public void testA() {
        System.
err.println("testA()");
    }
   
public void testB() {
        System.
err.println("testB()");
    }

}

 

import org.testng.annotations.Ignore;
import org.testng.annotations.Test;

public class ChildClass extends ParentClass {
   
@Test
    @Ignore
   
public void testC() {
        System.
err.println("testC()");
    }

   
@Test
    @Ignore
   
public void testD() {
        System.
err.println("testD()");
    }
}

 

 

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/

Reply-To: <[hidden email]>
Date: Tuesday, February 27, 2018 at 9:48 PM
To: <
[hidden email]>
Subject: Re: [testng-users] Re: How do I disable a subclass test?

 

On Tue, Feb 27, 2018 at 6:00 PM, Krishnan Mahadevan <[hidden email]> wrote:

Joshua,

 

I guess it does. I remember seeing unit tests that were added for checking that piece.

What happens when you try using that annotation ? 


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 Tue, Feb 27, 2018 at 8:25 PM, Joshua Fox <[hidden email]> wrote:

Does this allow disabling  tests on a subclass? Apparently not. See this from Cedric

https://stackoverflow.com/questions/13923801/ignore-a-class-in-testng

On Tuesday, February 27, 2018 at 11:48:46 AM UTC+2, Joshua Fox wrote:

How do I disable subclass tests?

My design includes a base class with
@Test
methods, and  subclasses without their own @Test methods. Using enabled=false on the class level does not disable the subclass as you might hope.

  // A.java

public abstract class A {

   @Test

   public void testMethod(){

     //...

     hookMethod();

     //...

   }

   protected  abstract void hookMethod();

}

 

// B.java

@Test (enabled=false) //doesn't disable test

public class B extends A {

   protected void  hookMethod() {

    // implementation

   }

}

protected  abstract void hookMethod();

}

 

// C.java

@Test //runs like B

public class C extends A {

   protected void  hookMethod() {

    // implementation

   }

}

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

 

--
You received this message because you are subscribed to a topic in the Google Groups "testng-users" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/testng-users/d_m7S0upJl8/unsubscribe.
To unsubscribe from this group and all its topics, 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.



 

--

 

 

JOSHUA FOX

Director, Software Architecture | Freightos

 

Error! Filename not specified.

 

T (Israel): <a href="tel:+972%2054-569-1165" target="_blank">+972-545691165 | T (US):  +<a href="tel:(312)%20340-0953" target="_blank">1-3123400953  

Smooth shipping.

 

 

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

--
You received this message because you are subscribed to a topic in the Google Groups "testng-users" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/testng-users/d_m7S0upJl8/unsubscribe.
To unsubscribe from this group and all its topics, 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.



 

--

 

 

JOSHUA FOX

Director, Software Architecture | Freightos

 

https://www.freightos.com/wp-content/uploads/2015/10/Freightos-logo-1-e1464518092684.png

 

T (Israel): <a href="tel:+972%2054-569-1165" target="_blank">+972-545691165 | T (US):  +<a href="tel:(312)%20340-0953" target="_blank">1-3123400953  

Smooth shipping.

 

 



 

--

 

 

JOSHUA FOX

Director, Software Architecture | Freightos

 

https://www.freightos.com/wp-content/uploads/2015/10/Freightos-logo-1-e1464518092684.png

 

T (Israel): +972-545691165 | T (US):  +1-3123400953  

Smooth shipping.

 

 

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

--
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: How do I disable a subclass test?

Joshua Fox
Thank you! Glad to know I uncovered a bug  😀

On Thu, Mar 1, 2018 at 5:45 AM, Krishnan Mahadevan <[hidden email]> wrote:

Joshua,

 

This is a bug. We need to get this fixed.

 

But with the way currently TestNG works, it may be a bit difficult.

 

You can track the discussions of this issue here : https://github.com/cbeust/testng/issues/1709

 

 

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/

From: <[hidden email]> on behalf of Joshua Fox <[hidden email]>
Reply-To: <[hidden email]>
Date: Wednesday, February 28, 2018 at 4:03 PM


To: <[hidden email]>
Subject: Re: [testng-users] Re: How do I disable a subclass test?

 

Unfortunately, with the following code, mvn test still runs the  test, printing ChildClassTest#hook(), whether I use either or both of Ignore and enabled=false

 

 

// ========= ParentClassTest.java =========

package pkg1;

 

import org.testng.annotations.Test;

 

public  abstract class ParentClassTest {

     @Test

     public void testc() throws Exception {

                hook();

     }

 

     protected abstract void hook();

}

 



// ========= ChildClassTest.java =========

package pkg1;

 

import org.testng.annotations.Ignore;

import org.testng.annotations.Test;

 

//Neither of these annotations prevents the test from running

@Ignore

@Test(enabled=false)

public class ChildClassTest extends ParentClassTest {

     @Override

     protected void hook() {

           System.out.println("ChildClassTest#hook()");

 

     }

}

 

 

 

On Wed, Feb 28, 2018 at 11:49 AM, Joshua Fox <[hidden email]> wrote:

My class setup is a little different. The subclass has no @Test methods of its own.

 

Thank you for the  @Ignore annotation!  I guess it new https://github.com/cbeust/testng/pull/861 and seems to do the job.

 

 

On Wed, Feb 28, 2018 at 5:43 AM, Krishnan Mahadevan <[hidden email]> wrote:

Joshua,

You mean you tried something like this using TestNG 6.14.3 ?

 

import org.testng.annotations.Test;

@Test
public class ParentClass {

   
public void testA() {
        System.
err.println("testA()");
    }
   
public void testB() {
        System.
err.println("testB()");
    }

}

 

import org.testng.annotations.Ignore;
import org.testng.annotations.Test;

public class ChildClass extends ParentClass {
   
@Test
    @Ignore
   
public void testC() {
        System.
err.println("testC()");
    }

   
@Test
    @Ignore
   
public void testD() {
        System.
err.println("testD()");
    }
}

 

 

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/

Reply-To: <[hidden email]>
Date: Tuesday, February 27, 2018 at 9:48 PM
To: <
[hidden email]>
Subject: Re: [testng-users] Re: How do I disable a subclass test?

 

On Tue, Feb 27, 2018 at 6:00 PM, Krishnan Mahadevan <[hidden email]> wrote:

Joshua,

 

I guess it does. I remember seeing unit tests that were added for checking that piece.

What happens when you try using that annotation ? 


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 Tue, Feb 27, 2018 at 8:25 PM, Joshua Fox <[hidden email]> wrote:

Does this allow disabling  tests on a subclass? Apparently not. See this from Cedric

https://stackoverflow.com/questions/13923801/ignore-a-class-in-testng

On Tuesday, February 27, 2018 at 11:48:46 AM UTC+2, Joshua Fox wrote:

How do I disable subclass tests?

My design includes a base class with
@Test
methods, and  subclasses without their own @Test methods. Using enabled=false on the class level does not disable the subclass as you might hope.

  // A.java

public abstract class A {

   @Test

   public void testMethod(){

     //...

     hookMethod();

     //...

   }

   protected  abstract void hookMethod();

}

 

// B.java

@Test (enabled=false) //doesn't disable test

public class B extends A {

   protected void  hookMethod() {

    // implementation

   }

}

protected  abstract void hookMethod();

}

 

// C.java

@Test //runs like B

public class C extends A {

   protected void  hookMethod() {

    // implementation

   }

}

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

 

--
You received this message because you are subscribed to a topic in the Google Groups "testng-users" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/testng-users/d_m7S0upJl8/unsubscribe.
To unsubscribe from this group and all its topics, 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.



 

--

 

 

JOSHUA FOX

Director, Software Architecture | Freightos

 

Error! Filename not specified.

 

T (Israel): <a href="tel:+972%2054-569-1165" target="_blank">+972-545691165 | T (US):  +<a href="tel:(312)%20340-0953" target="_blank">1-3123400953  

Smooth shipping.

 

 

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

--
You received this message because you are subscribed to a topic in the Google Groups "testng-users" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/testng-users/d_m7S0upJl8/unsubscribe.
To unsubscribe from this group and all its topics, 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.



 

--

 

 

JOSHUA FOX

Director, Software Architecture | Freightos

 

https://www.freightos.com/wp-content/uploads/2015/10/Freightos-logo-1-e1464518092684.png

 

T (Israel): <a href="tel:+972%2054-569-1165" target="_blank">+972-545691165 | T (US):  +<a href="tel:(312)%20340-0953" target="_blank">1-3123400953  

Smooth shipping.

 

 



 

--

 

 

JOSHUA FOX

Director, Software Architecture | Freightos

 

https://www.freightos.com/wp-content/uploads/2015/10/Freightos-logo-1-e1464518092684.png

 

T (Israel): <a href="tel:+972%2054-569-1165" value="+972545691165" target="_blank">+972-545691165 | T (US):  +<a href="tel:(312)%20340-0953" value="+13123400953" target="_blank">1-3123400953  

Smooth shipping.

 

 

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

--
You received this message because you are subscribed to a topic in the Google Groups "testng-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/testng-users/d_m7S0upJl8/unsubscribe.
To unsubscribe from this group and all its topics, 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.



--
 

JOSHUA FOX
Director, Software Architecture | Freightos



T (Israel): +972-545691165 | T (US):  +1-3123400953  
Smooth shipping.



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