Q:

Maven: mvn test gives error + Cannot find class in classpath

Running testng.xml directly from eclipse IDE, test suite gets executed but on executing testng.xml from maven gives error.
Running mvn compile, it says BUILD SUCCESS. But on running mvn testit gives error.
On running maven script through mvn test I am receiving below error:
[INFO]
[INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) @ XXX
--
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.18:test (default-test) @ XXX---
[INFO] No tests to run.
[INFO] Surefire report directory: \XXX\target\surefire-reports
Running TestSuite
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.295 s
[INFO] Finished at: 2015-11-09T17:34:34+05:30
[INFO] Final Memory: 17M/208M

--------------------
-----------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.
18:test (default-test) on project XXX: Exception in provider:
[ERROR] Cannot find class in classpath: com.XXX.tests.XXXX.classtoexecute
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal o
rg.apache.maven.plugins:maven-surefire-plugin:2.18:test (default-test) on project XXX: Exception in provider
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:212)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:153)

Please help.
Below is POM.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.xx.tests</groupId>
  <artifactId>XXX</artifactId>
  <version>1.0-SNAPSHOT</version>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.3</version>
        <configuration>
          <source>1.7</source>
          <target>1.7</target>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.18</version>
        <configuration>
          <forkCount>0</forkCount>
          <suiteXmlFiles>
            <suiteXmlFile>testng.xml</suiteXmlFile>
          </suiteXmlFiles>
        </configuration>
      </plugin>
    </plugins>
  </build>  
  <dependencies>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>2.46.0</version>
    </dependency>
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.8.5</version>
    </dependency>
    <dependency>
        <groupId>atu.testng</groupId>
        <artifactId>reports</artifactId>
        <version>5.0</version>
    </dependency>
  </dependencies>
</project>

TestNg is as belwo:
<
?xml version="1.0" encoding="UTF-8"?>
<suite name="XXXX" parallel="none" >
    <listeners>
        <listener class-name="atu.testng.reports.listeners.ATUReportsListener"></listener>
        <listener class-name="atu.testng.reports.listeners.ConfigurationListener"></listener>
        <listener class-name="atu.testng.reports.listeners.MethodListener"></listener>
    </listeners>
  <test name="test1" >
    <classes>
      <class name="com.XXX.tests.XXXX.classtoexecute"/>
    </classes>
 </test> 
</suite>

The project structure is as below:

A:

Converting non-maven to maven worked for my test project.
right click on project->Configure->Convert it to Maven

