title: Unable to run a TestNG with Gradle
body: <p>I have a simple code which runs with TestNG, but I am unable to run the same with Gradle, as it says no main method is found, which is, well, not surprising since I am using annotations.</p>
  
  <p>But in such a scenario, how to run the code if I must use Gradle.</p>
  
  <p>Kindly note, I am very new to Gradle, and do not harbour much knowledge about the same.</p>
  
  <p>Code:</p>
  
  <pre><code>import org.testng.annotations.AfterClass;
  import org.testng.annotations.BeforeClass;
  import org.testng.annotations.Test;
  
  public class tryTestNG
  {
      @BeforeClass
      public void setup()
      {
          System.out.println("I am in Setup");
      }
  
      @Test
      public void test()
      {
          System.out.println("I am in Test");
      }
  
      @AfterClass
      public void tearDown()
      {
          System.out.println("I am in tearDown");
      }
  }
  </code></pre>
  
  <p>The above code runs perfectly with TestNG Library. However not with Gradle.</p>
  
  <p>Here is my Gradle Build setup:</p>
  
  <pre><code>apply plugin: 'java'
  apply plugin: 'application'
  
  mainClassName = 'tryTestNG'
  sourceCompatibility = 1.7
  targetCompatibility = 1.7
  version = '1.0'
  
  repositories {
      mavenCentral()
  }
  
  test {
      useTestNG()
  }
  
  
  dependencies {
      compile group: 'org.testng', name: 'testng', version: '6.9.10'        
  }
  </code></pre>
  
  <p>The Gradle returns that there is no Main Method.</p>
  
  <pre><code>Working Directory: /home/avirup/MyWorkspace/JavaWorkspace/TestNGGradle
  Gradle User Home: /home/avirup/.gradle
  Gradle Distribution: Gradle wrapper from target build
  Gradle Version: 2.9
  Java Home: /usr/lib/jvm/java-8-oracle
  JVM Arguments: None
  Program Arguments: None
  Gradle Tasks: run
  
  :compileJava UP-TO-DATE
  :processResources UP-TO-DATE
  :classes UP-TO-DATE
  :runError: Main method not found in class tryTestNG, please define the main method as:
     public static void main(String[] args)
  or a JavaFX application class must extend javafx.application.Application
   FAILED
  
  FAILURE: Build failed with an exception.
  
  * What went wrong:
  Execution failed for task ':run'.
  &gt; Process 'command '/usr/lib/jvm/java-8-oracle/bin/java'' finished with non-zero exit value 1
  
  * Try:
  Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
  
  BUILD FAILED
  
  Total time: 0.514 secs
  </code></pre>
  
  <p>Thanks for your help.</p>