title: How to run a single test case (method) instead of whole test suite (class) using Selenium/TestNG/Maven
body: <p>So basically I am wondering how could I run a specific test case (a method) instead of running a whole class.</p>
  
  <p>I am running tests using a combination of Selenium/Maven/TestNG. My current testing setup looks something like this:</p>
  
  <p>simplified command to run tests:</p>
  
  <blockquote>
    <p>mvn test -DtestSuiteName="test"</p>
  </blockquote>
  
  <p>contents of test.xml used in the command above:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"&gt;
  &lt;suite name="Selenium Testng Template"&gt;
      &lt;test name="TestSuiteTest"&gt;
          &lt;classes&gt;
              &lt;class name="listeners.Test_Listener"/&gt;
              &lt;class name="tests.example_test_suite_name"/&gt;
          &lt;/classes&gt;
      &lt;/test&gt;
  &lt;/suite&gt;
  </code></pre>
  
  <p>What the Listener does is basically set up the enviroment for the tests, it starts a pre-configured WebDriver instance and closes it after all the tests are run. It looks something like this:</p>
  
  <pre><code>@Listeners(Listener_Helper)
  class Test_Listener implements IExecutionListener {
  
      @BeforeSuite
      void openBrowser(){
          prepareEnviroment()
      }
  
      @AfterSuite
      void closeBrowser(){
          cleanUp()
      }
  </code></pre>
  
  <p>Now to the contents of a example test file. It consists of a class that is somewhat of a test suite, and it that contains several methods, which are somewhat of a test case.</p>
  
  <pre><code>class example_test_suite_name {
  
      @Test(priority=1)
      void test_name_one() {
          //test instructions
      }
  
      @Test(priority=2)
      void test_name_two() {
          //test instructions
      }
  </code></pre>
  
  <p>To summarize, It's not a problem to launch a test suite - a class, but how do I launch a single test case - one method of a class? </p>
  
  <p>Let's say I only wanted to start "test_name_one" but not other methods that class contains. Unfortunately I couldn't find anything related to that on the web.</p>
  
  <p>Any hint regarding this matter would be highly appreciated</p>