Maven BUILD SUCCESSFUL but no tests executed in Selenium

maven surefire plugin
maven not running tests
maven surefire plugin example
how to run testng xml from maven
maven selenium no tests to run
no tests to run maven
testng reports in maven
maven not running selenium tests

EDIT: I've uploaded the project to github for anyone who'd like to take a look https://github.com/hfunsh/test-automation.git

I have written a few tests in Selenium using Intellij, the scripts run successfully in the IDE, but when I try to run them from the console I get a "BUILD SUCCESSFUL" message but no test execution.

I'm able to run other Maven Junit projects from the console, so I know this is most likely a configuration issue with my pom file, but I can't figure it out.

Here is an example of one of the Java class names (containing the word Test)

/Users/ser/IdeaProjects/SeleniunTrainingII/src/test/java/com/selenium/tests/junit/tests/TestLoginAmazon.java

2nd EDIT: I've now run "mvn clean verify" as suggested

    INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Selenium tests project 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ selenium-app ---
[INFO] 
[INFO] --- maven-failsafe-plugin:2.18.1:integration-test (default) @ selenium-app ---
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-api/2.2.1/maven-plugin-api-2.2.1.jar
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-descriptor/2.2.1/maven-plugin-descriptor-2.2.1.jar
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-artifact/2.2.1/maven-artifact-2.2.1.jar
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-project/2.2.1/maven-project-2.2.1.jar
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-settings/2.2.1/maven-settings-2.2.1.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-descriptor/2.2.1/maven-plugin-descriptor-2.2.1.jar (39 KB at 32.7 KB/sec)
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-api/2.2.1/maven-plugin-api-2.2.1.jar (13 KB at 10.2 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-profile/2.2.1/maven-profile-2.2.1.jar
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-artifact-manager/2.2.1/maven-artifact-manager-2.2.1.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-settings/2.2.1/maven-settings-2.2.1.jar (48 KB at 40.5 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-registry/2.2.1/maven-plugin-registry-2.2.1.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-artifact/2.2.1/maven-artifact-2.2.1.jar (79 KB at 64.3 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-model/2.2.1/maven-model-2.2.1.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-project/2.2.1/maven-project-2.2.1.jar (153 KB at 123.5 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-core/2.2.1/maven-core-2.2.1.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-profile/2.2.1/maven-profile-2.2.1.jar (35 KB at 27.6 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-parameter-documenter/2.2.1/maven-plugin-parameter-documenter-2.2.1.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-artifact-manager/2.2.1/maven-artifact-manager-2.2.1.jar (66 KB at 52.7 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-repository-metadata/2.2.1/maven-repository-metadata-2.2.1.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-registry/2.2.1/maven-plugin-registry-2.2.1.jar (30 KB at 23.1 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-error-diagnostics/2.2.1/maven-error-diagnostics-2.2.1.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-model/2.2.1/maven-model-2.2.1.jar (86 KB at 66.2 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-monitor/2.2.1/maven-monitor-2.2.1.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-repository-metadata/2.2.1/maven-repository-metadata-2.2.1.jar (26 KB at 19.3 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-toolchain/2.2.1/maven-toolchain-2.2.1.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-parameter-documenter/2.2.1/maven-plugin-parameter-documenter-2.2.1.jar (22 KB at 16.6 KB/sec)
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-error-diagnostics/2.2.1/maven-error-diagnostics-2.2.1.jar (13 KB at 9.6 KB/sec)
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-monitor/2.2.1/maven-monitor-2.2.1.jar (11 KB at 7.6 KB/sec)
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-toolchain/2.2.1/maven-toolchain-2.2.1.jar (37 KB at 26.9 KB/sec)
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-core/2.2.1/maven-core-2.2.1.jar (174 KB at 126.2 KB/sec)
[INFO] No tests to run.
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! The file encoding for reports output files should be provided by the POM property ${project.reporting.outputEncoding}.
[INFO] 
[INFO] --- maven-failsafe-plugin:2.18.1:verify (default) @ selenium-app ---
[INFO] No tests to run.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.536 s
[INFO] Finished at: 2016-01-14T10:10:47-05:00
[INFO] Final Memory: 11M/108M

EDIT: I've now added both the maven surefire AND failsafe plugins to my pom and it still isn't working.

Here is what my updated file looks like

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.selenium.test</groupId>
  <artifactId>selenium-app</artifactId>
  <packaging>pom</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>Selenium tests project</name>
  <description>Web Autotests simple project.</description>
  <url>http://maven.apache.org</url>

  <properties>
    <junit.version>4.11</junit.version>
    <testng.version>6.8.17</testng.version>
    <selenium.version>2.45.0</selenium.version>
    <compiler.version>1.7</compiler.version>
  </properties>


  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
          <source>${compiler.version}</source>
          <target>${compiler.version}</target>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.19.1</version>
        <configuration>
          <systemPropertyVariables>
            <propertyName>firefox</propertyName>
          </systemPropertyVariables>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
        <version>2.18.1</version>
        <executions>
          <execution>
            <configuration>
              <forkCount>3</forkCount>
              <reuseForks>true</reuseForks>
              <argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
              <testFailureIgnore>true</testFailureIgnore>
              <includes>
                <includesFile>**/*Test.java</includesFile>
              </includes>
            </configuration>
            <goals>
              <goal>integration-test</goal>
              <goal>verify</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>${junit.version}</version>
    </dependency>
    <dependency>
      <groupId>org.testng</groupId>
      <artifactId>testng</artifactId>
      <version>${testng.version}</version>
    </dependency>
    <dependency>
      <groupId>xml-apis</groupId>
      <artifactId>xml-apis</artifactId>
      <version>1.4.01</version>
    </dependency>
    <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-java</artifactId>
      <version>${selenium.version}</version>
    </dependency>
  </dependencies>
</project>

you need to add either maven-surefire-plugin or maven-failsafe-plugin to your POM and then run mvn clean test command and tests should start executing

Sample excerpt:

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.18.1</version>
                <executions>
                    <execution>
                        <configuration>
                            <forkCount>3</forkCount>
                            <reuseForks>true</reuseForks>
                            <argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
                            <testFailureIgnore>true</testFailureIgnore>
                            <includes>
                                <includesFile>**/*Test.java</includesFile>
                            </includes>
                        </configuration>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

EDIT: Your package name in the TestLogin.java was wrong. EDIT: Also your packaging in POM.xml is set to pom..You need to set it to jar

Mvn build success but no tests are executed, Surefire has a mechanism to figure out whether to run JUnit or TestNG. Probably something in your dependencies/code is making surefire try to  Maven build successful but no tests run I have Maven installed with Jenkins and Eclipse. I created a new Maven project and if I right-click the project and select "Run-As" and then click "Maven clean" or "Maven test", it builds successfully but doesn't actually run any tests.

i have faced the same issue but it is resolved. Steps i have changed:

Step1: our Test name should end with "Test".

Step2: We should check the Properties of our project that should include M2_REPO

SelectProject in eclipse right click->Properties->Java BuildPath->Libraries

check the availability of the M2_REPO, if it is not there create a variable with that name, give the local m2 directory path.

and click on Apply and Ok.

check in the local machine for m2 folder and paste the path over here.

Step3: right click on the project ->Maven->UpdateProject.

Step4: right click on the project-> RunAs-> Maven Test.

Maven build successful but no tests run : selenium, Maven build successful but no tests run. I created a new Maven project and if I right-click the project and select "Run-As" and then click "Maven clean" or "Maven test", it builds successfully but doesn't actually run any tests. Edit: Everything is in src/test/java and not src/main/java. Maven is installed and build is successful. I am making Maven project with Testng and trying to execute testcase. If run through Eclipse , gets executed perfectly. But if executed through command prompt using maven -mvn compile and mvn test -build is successful, but the test case is not executed.

Add maven-surefire-plugin to your pom to trigger testng runs. You can get more information on the maven surefire plugin in this documentation link.

Sample plugin entry in pom:

<plugins>
    [...]
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.19.1</version>
        <configuration>
          <systemPropertyVariables>
            <propertyName>firefox</propertyName>
          </systemPropertyVariables>
        </configuration>
      </plugin>
    [...]
</plugins>

Maven Surefire Plugin – Using TestNG, This allows flexible configuration of the tests to be run. Likewise, the excludedGroups parameter can be used to run all but a certain set of groups. You can specify -1 and this will put TestNG in debug mode (no longer  While executing my pom.xml file through maven test my BUILD is getting SUCCESSFUL but my testng.xml is not executing. I tried with executing 13 classes and with single class for both the time it gives the same result. I don't know why it is copying 0 resource. Please check my pom.xml below:

Please make sure that your test directory is included in pom.xml file

<build>
    <testSourceDirectory>your_test_source_directory</testSourceDirectory>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.19.1</version>
        <configuration>
            <testSourceDirectory>${project.build.testSourceDirectory}</testSourceDirectory>                      
            <suiteXmlFiles>
                <suiteXmlFile>testng.xml</suiteXmlFile>
            </suiteXmlFiles> 
            <includes>
            <include>**.java</include>
            </includes>
         </configuration>
     </plugin>
</build>

Maven Surefire Plugin – Inclusions and Exclusions of Tests, There are certain times when some tests are causing the build to fail. An include/exclude pattern can be an ant-style path expression, but The character (?) within non-regex pattern replaces one character in file name or path. To have the plugin scan dependencies to find test classes to execute, use  Summary Tests are not getting executed by maven, but those are getting executed by runner file Expected Behavior Cucumber feature files should be executed by maven Current Behavior Maven console is showing no tests to run Steps to Reprod

I am new to maven and automation, and I faced this same issue. The "TESTS" were not getting executed. However, to resolve this issue you just need to prefix your package name with 'com.packt.'

testng.xml is not executing when we run pom.xml for maven project , While executing my pom.xml file through maven test my BUILD is getting SUCCESSFUL but my testng.xml is not executing. enter image  Selenium WebDriver is great for browser automation. But, when using it for testing and building a test framework, it feels underpowered. Integrating Maven with Selenium provides following benefits. Apache Maven provides support for managing the full lifecycle of a test project.

Cucumber tests are not getting executed by maven, "No tests to run , Summary Tests are not getting executed by maven, but those are Behavior Maven console is showing no tests to run Steps to Reprod <dependency> <​groupId>org.seleniumhq.selenium</groupId> If you still have problem, first clone and build https://github.com/cucumber/cucumber-java-skeleton to  Running Selenium Tests with Maven Coveros Staff November 15, 2016 Agile , Blogs , Software Tools , Testing 1 comment One of the most important things in software testing is integrating tests with the build tool that your project uses.

How to run testng.xml from maven, Learn to integrate testng tests to run during build time to automate testng maven example, we will lean how to execute testng tests using maven build [​WARNING] For this reason, future Maven versions might no longer support [​INFO] BUILD SUCCESS But, I have this issue in another project and also your project. Configure Selenium Continuous Integration with Maven project is not a big task. You just need to follow a few sets of steps and you are done with that. But making that project work with Maven is a little tricky and that requires few configurations around your project. Once you are done with that only then your test will be recognized by the

Users - There are no tests to run, Hi, I have set up maven to run my test. org.apache.maven.plugins But when I run mvn test I get: [WARNING] [INFO] BUILD SUCCESSFUL Selenium Maven. Maven is the latest build testing tool. It has several new features as compare to Ant, like dependency, etc. Maven is a project build or project management tool. It is used to check the compilation issues between framework components whenever multiple test engineer integrates their files into the same framework.

Comments
  • why maven command are you executing to get that output? Did you just execute mvn clean?
  • I ran "mvn clean test".
  • which folder contains your selenium tests?
  • The tests are stored in /Users/user/IdeaProjects/SeleniumTraining/
  • @user2712611, This is most likely due to your directory structure. Maven uses an arbitrary directory structure. src/main/java is your main java code src/test/java is your tests. Maven will read this directory when executing mvn test by default.
  • Thanks, I've added both plugins and neither worked. I've posted my updated pom file in the original post
  • apologies..actually what i meant is you need to include any one of them and it seems you haven't replaced the includes tag with the relevant file name of the test.. also what maven goals are you running?
  • I initially added each plugin individually, before deciding to try both at the same time. I also made sure my class file name matched the pattern in the includes tag (i.e it ends with Test.java). I don't know anything about maven goals unfortunately.
  • I attempted "mvn clean test" and "mvn test". Thanks
  • your test class name is "TestLoginAmazon" but your pattern in POM is *Test.java which will not match. also try mvn clean verify
  • Thanks, I've tried this, but it didn't work. I've posted my updated pom file in the original post
  • pls try mvn -x to figure out the debug info whats going on with the run sequence.