@BeforeMethod is still executed even if execution is skipped in @BeforeClass

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

@BeforeMethod is still executed even if execution is skipped in @BeforeClass

Gajanan Mahajan
I've tests where based on some condition, I skip execution in `@BeforeClass` itself like -

        @BeforeClass(alwaysRun = true)
    public void beforeClass() {
    if (someCondition) {
    //do something
    } else {
    throw new SkipException(
    "THESE TESTS ARE NOT INTENDED TO EXECUTE: ");
    }
           }
    }
    
    @BeforeMethod
    public void beforeMethod() {
    // do something
    }

But I run tests, skipExecution statement is executed still execution goes in method annotated with `@BeforeMethod` and code under it is executed which results my tests in failure instead of skip status.

Is this known bug in TestNG or issue with TestNG version? I'm using `TestNG 6.9.10` version

--
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: @BeforeMethod is still executed even if execution is skipped in @BeforeClass

Krishnan Mahadevan
What happens when you try the same using the latest released version of TestNG [ as of today its 6.13.1] ?

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 Fri, Dec 22, 2017 at 12:13 PM, Gajanan Mahajan <[hidden email]> wrote:
I've tests where based on some condition, I skip execution in `@BeforeClass` itself like -

        @BeforeClass(alwaysRun = true)
    public void beforeClass() {
    if (someCondition) {
    //do something
    } else {
    throw new SkipException(
    "THESE TESTS ARE NOT INTENDED TO EXECUTE: ");
    }
           }
    }
    
    @BeforeMethod
    public void beforeMethod() {
    // do something
    }

But I run tests, skipExecution statement is executed still execution goes in method annotated with `@BeforeMethod` and code under it is executed which results my tests in failure instead of skip status.

Is this known bug in TestNG or issue with TestNG version? I'm using `TestNG 6.9.10` version

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