使用maven执行TestNG测试时的Maven跳过测试(mvn测试)

时间:2018-02-20 06:46:19

标签: java maven testng maven-3

我使用selenium创建了测试用例,之前我能够使用maven(来自命令行和eclipse)执行我的测试用例。但现在它不起作用。请帮忙

请在下面找到控制台日志:(运行为 - > maven测试

[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

我没有收到任何错误,它成功构建项目。 但跳过所有测试用例

请在下面找到我的pom.xml配置:

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>

请在下方找到E2E.xml:

<?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>

1 个答案:

答案 0 :(得分:0)

问题已经解决了,问题出在我的DataProvider方法上它是非静态的,一旦我将我的dataProvider方法改为静态,它就开始完美运行。