1

I have simple selenium test (non junit) which I want to run through Maven. I have kept my class under src/test.

POM file is as below:

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
    <execution>
        <id>my-execution</id>
        <phase>test</phase>
        <goals>
            <goal>java</goal>
        </goals>
    </execution>
</executions>
<configuration>
    <mainClass>SeleniumMavenTest.SeleniumMavenTest</mainClass>
        <classpathScope>test</classpathScope>
</configuration>

Now Maven is embedded as a plug-in in Eclipse. I am running Maven clean then Maven install but I am getting MojoExecutionException (Class not found).

An error as below:

java.lang.ClassNotFoundException: SeleniumMavenTest.SeleniumMavenTest

Can anyone tell me how to trigger a simple test(non JUnit) using Maven and what is going wrong here?

Dima Kozhevin
  • 3,602
  • 9
  • 39
  • 52
Nilesh G
  • 103
  • 1
  • 9
  • Please add the full log output and not only excerpts...also please check on plain command line first...using exec-maven-plugin? Furthermore the full pom file would be helpful. – khmarbaise Dec 29 '18 at 08:34
  • I am new to maven and since it is embedded in eclipse , we can run it through eclipse commands only (instead of running it through command line and ran it through eclipse run configuration. but got same output).Regarding POM , rest of the POM contains dependencies. – Nilesh G Dec 29 '18 at 08:44
  • 1
    Can you please add the whole output of the command run ..? How exactly have you called Maven? Which Maven version do you use? Your answer does not help... – khmarbaise Dec 29 '18 at 08:47
  • You could start with a working example (e.g. [this one here](https://github.com/Ardesco/Selenium-Maven-Template)) and then customize it to your needs. If you ask a question here instead, you should show your complete `pom.xml` and log output to get an answer to what goes wrong in your particular case. – howlger Dec 29 '18 at 10:36
  • Entire POM is very big , important part is maven plug-in which I took for https://stackoverflow.com/questions/4060613/from-maven-how-do-i-run-a-class-that-lives-under-src-test-java. Eclipse give you option to run maven test command by right clicking on POM . I am doing that only but getting class not found exception – Nilesh G Dec 29 '18 at 12:33
  • @NileshG Does your project contain the file `src/test/java/SeleniumMavenTest/SeleniumMavenTest.java`? If yes and if you assume that you have this issue because you are running Maven from inside Eclipse, install Maven and run your `pom.xml` from the command line or try to run a Selenium test via Maven in Eclipse that's known to work (like e. g. [this one](https://github.com/Ardesco/Selenium-Maven-Template)). – howlger Dec 29 '18 at 13:26

0 Answers0