Search code examples
javamaventestngmaven-3

Maven Skipping Test while executing TestNG test using maven (mvn test)


I have created test case using selenium, earlier i was able to execute my test case using maven (from command line and from eclipse ). but now it is not working. please help

Please find console log below: ( run as --> maven test)

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building NoonAutomation 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ NoonAutomation ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 3 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) @ NoonAutomation ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ NoonAutomation ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.5.1:testCompile (default-testCompile) @ NoonAutomation ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ NoonAutomation ---
[INFO] Surefire report directory: /Users/username/Documents/GitRepo/NoonWeb/NoonAutomation/target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running TestSuite
Tests run: 4, Failures: 0, Errors: 0, Skipped: 4, Time elapsed: 0.463 sec - in TestSuite

Results :

Tests run: 4, Failures: 0, Errors: 0, Skipped: 4

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.877 s
[INFO] Finished at: 2018-02-20T12:05:05+05:30
[INFO] Final Memory: 13M/309M
[INFO] ------------------------------------------------------------------------

Maven configuration

I am not getting any error, It building project successfully. but skipping all test cases

Please find my pom.xml configuration below:

build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.18.1</version>
                    <configuration>
                        <suiteXmlFiles>
                            <suiteXmlFile>./testxml/E2E.xml</suiteXmlFile>
                        </suiteXmlFiles>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-report-plugin</artifactId>
                    <version>2.15</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.5.1</version>
                    <configuration>
                        <systemPropertyVariables>
                            <environment>${env}</environment>
                            <os>${os}</os>
                        </systemPropertyVariables>
                        <source>${compiler.version}</source>
                        <target>${compiler.version}</target>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

Please find E2E.xml Below:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">

<suite name="Noon  Automation Suite" parallel="tests" thread-count="5" >

    <parameter name="workBookName" value="testdata\\Web_Automation.xls" />
    <parameter name="sheetName" value="SmokeTestCase" />

    <!-- parameter for device host and port -->
    <parameter name="deviceHost" value="localhost" />
    <parameter name="devicePort" value="4444" />
    <parameter name="webSite" value="site URL" />
    <test name="E2E Test  chrome" thread-count="2" parallel="true">
    <parameter name="browserName" value="chrome_mac"/>
        <classes>
            <class name="com.Noon.E2E.SmokeTest">

            </class>
        </classes>
    </test>

</suite>

Solution

  • The issue has been solved, the problem was with my DataProvider method it was non-static, once i changed my dataProvider method to static it start working perfectly.