title: How to execute @BeforeMethod of another class in case of multiple testng classes
body: <p>Problem Statement : I have got multiple testng classes which have @BeforeMethod &amp; @Test methods &amp; some tests are invoked via another test method. The BeforeMethod methods in such a case does not get executed.</p>
  
  <p>For e.g. </p>
  
  <pre><code>public class A {
  
      @BeforeMethod
      public void preCheck(){
           System.out.println("Pre-Check A");
      }
  
      @Test
      public void check(){
           System.out.println("Check A");
           B objB = new B();
           objB.check();
      }
  }
  
  public class B {
  
      @BeforeMethod
      public void preCheck(){
          System.out.println("Pre-Check B");
      }
  
      @Test
      public void check(){
          System.out.println("Check B");
      }
  }
  </code></pre>
  
  <p>When I execute class A as Testng class, I get the following output</p>
  
  <pre><code>Pre-Check A
  Check A
  Check B
  </code></pre>
  
  <p>Whereas desired output is </p>
  
  <pre><code>Pre-Check A
  Check A
  Pre-Check B
  Check B
  </code></pre>
  
  <p>How can I achieve the same ?</p>