title: run test classes from other path in testng.xml file
body: <p>I am fairly beginner in TestNG, Maven &amp; IntelliJ. I have created a new maven project and defined a 'runtest' class under src/main/java. I am able to run testcases through testng.xml if I specify test classes under src/main/java. </p>
  
  <p>However, I want to specify my test classes inside src/test/java. If I specify any test class 'test1.java' under src/test/java and run, it gives error : 
  Error: 
  Cannot find class in classpath: java/test1</p>
  
  <p>Workarounds I already tried:</p>
  
  <ol>
  <li>In testng.xml file, giving full path of the test case - starting from /Users/ (Note: I am using MAC)</li>
  <li>In testng.xml file, giving full path of the test case - starting from src/</li>
  <li>Specified additional classpath in pom.xml under maven-surefire-plugin (over here also I specified full path, path from project base directory etc.)</li>
  <li>I tried to clear cache, however no difference</li>
  </ol>
  
  <p>Other observations:</p>
  
  <p>Intellij shows me an error when I specify path in testng.xml file. It gives me options to create class XXXX. When I click on create class - it gives me 2 locations (src/main/java &amp; src/test/java). I already have respective test class under src/test/java. Why is it not accepting?</p>
  
  <p>I tried to check my classpath in Mac, but I'm not having much success. </p>
  
  <p>Any help will be appreciated. </p>
  
  <p>Thanks</p>
  
  <p>Based on comments, editing my questions. Specifying my code details.  </p>
  
  <p>I want to call testng.xml file from TestNG class. Here is my TestNG Class: 
  runtests.java in src/main/java</p>
  
  <p>public static TestNG testng;</p>
  
  <pre><code>public static void main(String[] args) {
  
      try {
  
          testng = new TestNG();
          testng.setPreserveOrder(true);
          testng.setVerbose(0);
          testng.setTestSuites(Arrays.asList("config/testng.xml"));
          testng.run();
          }
       catch (Exception e) {
          //Catch exception if any
          System.err.println("Error: " + e.getMessage());
      }
  
      }
  </code></pre>
  
  <p>The reason I want to do this way is, I want to create maven build and I want to specify testng.xml editable to user. So, if someone wants to run just 1 test case, they can edit testng.xml and run only 1 test case. </p>
  
  <p>Here is my testng.xml in config/testng.xml</p>
  
  <p>suite name="Testing" verbose="0"<br>
      test name="Test1"<br>
          classes<br>
              class name="java/test1"<br>
          classes<br>
   test  </p>
  
  <p>over here in the class name, I am not able to add classes from other location. I am only able to specify classes mentioned in src/main/java. I want to specify classes mentioned in src/test/java.</p>
  
  <p>One more thing, I want to do is: I want to create one configuration file, that will go with build and will be editable. So, if user wants to edit configutation (i.e. change server name etc.) user can edit configuration file and run test cases. </p>