title: How to avoid executing the method written in @AfterSuite if a single test is executed as 'TestNG Test' or using the 'Run' command provided by plugin
body: <p>BaseTest Class</p>
  <pre><code>public class BaseTest extends Base {
      LoginPage login;
      Logger logger = Logger.getLogger(Base.class);
  
      @BeforeMethod()
      public void setUp() throws IOException, IOException {
          logger.info(&quot;starting initialisation method from base class&quot;);
          initialisation();
          logger.info(&quot;completed initialisation method from base class&quot;);
          login = new LoginPage();
          logger.info(&quot;initialising login page and profile page object&quot;);
      }
      @AfterMethod
      public void tearDown() {
          logger.info(&quot;starting tear down method&quot;);
          Base.getDriver().close();
          logger.info(&quot;ending tear down method&quot;);
      }
      @AfterSuite
      public void sendEmailWithExtentReport() throws IOException {
          logger.info(&quot;starting sendEmailWithExtentReport&quot;);
          Utilities.sendJavaMailAfterExecution();
          logger.info(&quot;ending sendEmailWithExtentReport&quot;);
          
  }
  
  </code></pre>
  <p>LoginTest class</p>
  <pre><code>public class LoginTest extends BaseTest {
  @Test(priority = 0,description = &quot;Test case to verify login button is present or not&quot;)
      public void loginPageLoadingTest() throws IOException, InterruptedException {
          logger.info(&quot;starting loginPageLoadingTest&quot;);
          Thread.sleep(2000);
          Assert.assertEquals(login.verifyLoginButton(), true);
          logger.info(&quot;ending loginPageLoadingTest&quot;);
      }
  @Test(priority = 1, description = &quot;Test case to verify login page title&quot;)
      public void loginPageTitleTest() throws IOException, InterruptedException {
          logger.info(&quot;starting loginPageTitleTest&quot;);
          Thread.sleep(2000);
          Assert.assertEquals(login.getLoginPageTitle(), &quot;Console&quot;);
          logger.info(&quot;ending loginPageTitleTest&quot;);
      }
  }
  </code></pre>
  <p>testng-console.xml</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;!DOCTYPE suite SYSTEM &quot;https://testng.org/testng-1.0.dtd&quot;&gt;
  &lt;suite name=&quot;Suite&quot;&gt;
      &lt;listeners&gt;
          &lt;listener class-name=&quot;com.analyzer.MyTransformer&quot; /&gt;
          &lt;listener class-name=&quot;com.utilities.TestListener&quot;&gt;&lt;/listener&gt;
      &lt;/listeners&gt;
      &lt;test thread-count=&quot;5&quot; name=&quot;Test&quot;&gt;
          &lt;classes&gt;
              &lt;class name=&quot;com.ui.tests.BaseTest&quot; /&gt;
              &lt;class name=&quot;com.ui.tests.LoginTest&quot; /&gt;
              &lt;class name=&quot;com.ui.tests.FilterTest&quot; /&gt; --&gt;
          &lt;/classes&gt;
      &lt;/test&gt; &lt;!-- Test --&gt;
  &lt;/suite&gt; &lt;!-- Suite --&gt;
  </code></pre>
  <p>I need to skip the method in @AfterSuite if i am only executing the single test case from multiple test cases in LoginTest class without using testng.xml file, so that I can verify each test case separately. Right now when individual test is executed the method in @AfterSuite is also getting executed. I want to execute the method in @AfterSuite only when test cases are executed using testng.xml file. How can i add a condition in @AfterSuite to achieve this. Also i am using this command '''mvn clean test -Dbrowsername=chrome''' from command prompt. My testng file name is testng-console.xml .The method in @AfterSuite should only get executed when using the tesng-console.xml. Please help.</p>