title: java.lang.IllegalArgumentException while fetching the name of method marked as test (using @test) in the before method
body: <p><strong>Problem Statement</strong>
  I want to get the name of the method which is marked as the test method using @test in the @before test.</p>
  
  <p>After researching, I found a solution &amp; following is my implementation :</p>
  
  <pre><code>import java.lang.reflect.Method;
  import org.testng.annotations.*;
  
  public class myTestClass {
  
      @BeforeSuite
      public void configureEnvironment(){
           // does some basic tasks
      }
  
      @BeforeTest
      public void configureTest(Method m){
           System.out.println("Test Case Name : "+m.getName());
      }
  
      @Test
      public void TestABC(){}
  
      @Test 
      public void TestXYZ(){}
  
      @AfterTest
      public void testCleanUp(){
          //performs test clean up activities
      }
  }
  </code></pre>
  
  <p><em>PS: It's a typed in code for explanation purpose &amp; therefore please ignore any syntax errors.</em></p>
  
  <p>I am expecting the following <strong>Output</strong> ::</p>
  
  <pre><code>Test Case Name : TestABC
  Test Case Name : TestXYZ
  </code></pre>
  
  <p>Following is my <strong>testng xml</strong> ::</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
   &lt;suite name="My_Test_Suite" parallel="false"&gt;
   &lt;test name="My_TESTS"&gt;
      &lt;classes&gt;
        &lt;class name="myPackage.myTestClass" /&gt;
      &lt;/classes&gt; 
    &lt;/test&gt; 
  &lt;/suite&gt; 
  </code></pre>
  
  <p>However I am getting the following <strong>exception</strong> :: </p>
  
  <pre><code>FAILED CONFIGURATION: @BeforeTest configureTest
  java.lang.IllegalArgumentException: wrong number of arguments
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
      at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:510)
      at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:211)
      at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)
      at org.testng.TestRunner.beforeRun(TestRunner.java:647)
      at org.testng.TestRunner.run(TestRunner.java:615)
      at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
      at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
      at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
      at org.testng.SuiteRunner.run(SuiteRunner.java:261)
      at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
      at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
      at org.testng.TestNG.runSuitesSequentially(TestNG.java:1185)
      at org.testng.TestNG.runSuitesLocally(TestNG.java:1110)
      at org.testng.TestNG.run(TestNG.java:1018)
      at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:112)
      at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:205)
      at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:176)
  </code></pre>
  
  <p>As per the TestNG documentation, this is a native dependency injection where either the info is injected by testng or by dataprovider. Since I want to use the testng approach, I have implemented the above solution.</p>
  
  <p>Could anyone please provide their inputs as to what am I missing here &amp; if there is any incorrect implementation.</p>
  
  <p><em>PS: I have seen many duplicate issues but nobody has reported this exception &amp; therefore decided to file this question.</em></p>