当我使用maven surefire使用POM文件执行TestNG.xml时,TestNG测试没有运行

当我使用maven surefire使用POM文件执行TestNG.xml时,TestNG测试没有运行,maven,selenium-webdriver,testng,pom.xml,maven-surefire-plugin,Maven,Selenium Webdriver,Testng,Pom.xml,Maven Surefire Plugin,当我使用Maven surefire使用POM文件执行testng.xml时,正在运行0个测试 我使用testng.xml运行了一些selenium测试。 当我将testng.xml文件作为testng测试套件运行时,它运行良好 但是,当我包含testng.xml文件(如下所示)时,它不会运行: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>mave

当我使用Maven surefire使用POM文件执行testng.xml时,正在运行0个测试

我使用testng.xml运行了一些selenium测试。 当我将testng.xml文件作为testng测试套件运行时,它运行良好

但是,当我包含testng.xml文件(如下所示)时,它不会运行:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.14.1</version>
    <configuration>
        <suiteXmlFiles>
            <suiteXmlFile>testng.xml</suiteXmlFile>
        </suiteXmlFiles>
    </configuration>
</plugin>
请告知

即使在我的POM.xml文件中给出了Testng.xml的完整路径,这个问题仍然存在

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.14.1</version>
            <configuration>
                <suiteXmlFiles>
                    <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
        </plugin>

[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for SAPAutomation:SAPAutomation:jar:0.0.1-SNAPSHOT
[WARNING] 'dependencies.dependency.systemPath' for com.oracle:ojdbc14-10.2.0.4.0:jar should not point at files within the project directory, ${basedir}/src/lib/ojdbc14.jar will be unresolvable by dependent projects @ line 154, column 16
[WARNING] 'dependencies.dependency.systemPath' for org.monte.screenrecorder:MonteScreenRecorder:jar should not point at files within the project directory, ${basedir}/src/lib/MonteScreenRecorder.jar will be unresolvable by dependent projects @ line 163, column 15
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO] 
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building SAPAutomation 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ SAPAutomation ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\AutomationWorkSpace\SAPAutomation\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ SAPAutomation ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ SAPAutomation ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) @ SAPAutomation ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 35 source files to C:\AutomationWorkSpace\SAPAutomation\target\test-classes
[INFO] 
[INFO] --- maven-surefire-plugin:2.14.1:test (default-test) @ SAPAutomation ---
[INFO] Surefire report directory: C:\AutomationWorkSpace\SAPAutomation\target\surefire-reports

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

Results :

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

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.402 s
[INFO] Finished at: 2015-04-14T17:31:11+00:00
[INFO] Final Memory: 22M/167M
[INFO] ------------------------------------------------------------------------

org.apache.maven.plugins
maven surefire插件
2.14.1
src/test/resources/testng.xml
[信息]正在扫描项目。。。
[警告]
[警告]为SAPAutomation:SAPAutomation:jar:0.0.1-SNAPSHOT构建有效模型时遇到一些问题
[警告]'dependencies.dependency.systemPath'for com.oracle:ojdbc14-10.2.0.4.0:jar不应指向项目目录中的文件,${basedir}/src/lib/ojdbc14.jar将无法由依赖项目在第154行第16列解决
[警告]'dependencies.dependency.systemPath'for org.monte.screenrecorder:MonteScreenRecorder:jar不应指向项目目录中的文件,${basedir}/src/lib/MonteScreenRecorder.jar将无法由dependency projects在第163行第15列解决
[警告]
[警告]强烈建议修复这些问题,因为它们会威胁到构建的稳定性。
[警告]
[警告]出于这个原因,未来的Maven版本可能不再支持构建这种格式错误的项目。
[警告]
[信息]
[信息]使用线程计数为1的生成器org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder
[信息]
[信息]------------------------------------------------------------------------
[信息]楼宇自动化0.0.1-SNAPSHOT
[信息]------------------------------------------------------------------------
[信息]
[信息]---maven资源插件:2.6:resources(默认资源)@SAPAutomation---
[信息]使用“UTF-8”编码复制筛选的资源。
[信息]跳过不存在的资源目录C:\AutomationWorkSpace\SAPAutomation\src\main\resources
[信息]
[信息]---maven编译器插件:3.3:compile(默认编译)@SAPAutomation---
[信息]无需编译-所有类都是最新的
[信息]
[信息]---maven资源插件:2.6:testResources(默认testResources)@SAPAutomation---
[信息]使用“UTF-8”编码复制筛选的资源。
[信息]正在复制3个资源
[信息]
[信息]---maven编译器插件:3.3:testCompile(默认testCompile)@SAPAutomation---
[信息]检测到更改-重新编译模块!
[信息]将35个源文件编译为C:\AutomationWorkSpace\SAPAutomation\target\test类
[信息]
[信息]---maven surefire插件:2.14.1:test(默认测试)@SAPAutomation---
[信息]Surefire报告目录:C:\AutomationWorkSpace\SAPAutomation\target\Surefire报告
-------------------------------------------------------
T T S T S
-------------------------------------------------------
运行测试套件
测试运行:0,失败:0,错误:0,跳过:0,所用时间:0.501秒
结果:
测试运行:0,失败:0,错误:0,跳过:0
[信息]------------------------------------------------------------------------
[信息]建立成功
[信息]------------------------------------------------------------------------
[信息]总时间:7.402秒
[信息]完成时间:2015-04-14T17:31:11+00:00
[信息]最终内存:22M/167M
[信息]------------------------------------------------------------------------

在maven surefire插件中,提供从项目下到testng.xml文件的完整路径——例如:
src/test/resources/testng.xml

您需要为Maven提供testng.xml文件的完整路径以获取它。

您可以将您的testng.xml文件与pom文件一起直接放在项目下,然后它将执行您的测试套件。

上述问题通过使用上述版本中的Maven Surefire插件的更新得到解决xml。整个装置从此以后都过着幸福的生活!!
谢谢

在与Rahul Sir的视频一起进行Maven与TestNG集成的实践时,我遇到了同样的情况(问题)

在没有TestNG.xml的情况下,POM.xml能够在使用CLI中的“mvn test”命令调用时执行所有测试

然而,我注意到,如果我只是直接从testng.xml运行测试,即“作为testng套件运行”,那么就不会运行任何测试用例

在仔细查看我的测试java类时,我发现,对于在测试用例(方法)之前使用@test注释,导入库是-->import org.junit.test;因为即使jUnit在它的库中也有一个测试类

但是由于我们使用的是TestNG,因此我们必须使用这个导入-->import org.TestNG.annotations.Test

当我们使用项目模板(即Maven原型快速启动模板)在Eclipse中创建Maven项目时,它创建了两个并行文件夹结构->一个用于java(具有对象模型和实用程序),另一个用于测试(包含测试用例)。因此,默认情况下,有一个AppTest.java类,它使用jUnit库进行@Test注释

因此,在eclipse中创建Maven项目之后,我们应该在pom.xml中添加TestNG依赖项,以防我们知道将使用TestNG执行

我可以通过使用import org.testng.annotations.Test解决这个问题;在我的每个测试类中

TestNG SuiteXML将只在@Test注释上工作,而org.TestNG.annotations.Test用于类


希望这也能解决你的错误。谢谢。

我仍然收到0测试成功运行的消息。" -------------------------------------------------------
<suite name="Suite" parallel="tests">
        <listeners>
            <listener class-name="com.SAPAutomation.Listners.RetryListener"/>
        </listeners>

  <test name="Test1">
        <parameter name="TestCaseId" value="TC1" />
        <classes>
          <class name="com.xyz.abc.MyAutomationTestByXML"/>
        </classes>
      </test> 

    <test name="Test2">
        <parameter name="TestCaseId" value="TC2" />
        <classes>
          <class name="com.xyz.abc.MyAutomationTestByXML"/>
        </classes>
    </test> 


    <test name="Test3">
        <parameter name="TestCaseId" value="TC3" />
        <classes>
          <class name="com.xyz.abc.MyAutomationTestByXML"/>
        </classes>
    </test> 
</suite>
[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for SAPAutomation:SAPAutomation:jar:0.0.1-SNAPSHOT
[WARNING] 'dependencies.dependency.systemPath' for com.oracle:ojdbc14-10.2.0.4.0:jar should not point at files within the project directory, ${basedir}/src/lib/ojdbc14.jar will be unresolvable by dependent projects @ line 153, column 16
[WARNING] 'dependencies.dependency.systemPath' for org.monte.screenrecorder:MonteScreenRecorder:jar should not point at files within the project directory, ${basedir}/src/lib/MonteScreenRecorder.jar will be unresolvable by dependent projects @ line 162, column 15
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO] 
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building SAPAutomation 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ SAPAutomation ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\AutomationWorkSpace\SAPAutomation\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ SAPAutomation ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ SAPAutomation ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) @ SAPAutomation ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 35 source files to C:\AutomationWorkSpace\SAPAutomation\target\test-classes
[INFO] 
[INFO] --- maven-surefire-plugin:2.14.1:test (default-test) @ SAPAutomation ---
[INFO] Surefire report directory: C:\AutomationWorkSpace\SAPAutomation\target\surefire-reports

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

Results :

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

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.137 s
[INFO] Finished at: 2015-04-09T15:01:01+00:00
[INFO] Final Memory: 24M/277M
[INFO] ------------------------------------------------------------------------
<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.14.1</version>
            <configuration>
                <suiteXmlFiles>
                    <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
        </plugin>

[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for SAPAutomation:SAPAutomation:jar:0.0.1-SNAPSHOT
[WARNING] 'dependencies.dependency.systemPath' for com.oracle:ojdbc14-10.2.0.4.0:jar should not point at files within the project directory, ${basedir}/src/lib/ojdbc14.jar will be unresolvable by dependent projects @ line 154, column 16
[WARNING] 'dependencies.dependency.systemPath' for org.monte.screenrecorder:MonteScreenRecorder:jar should not point at files within the project directory, ${basedir}/src/lib/MonteScreenRecorder.jar will be unresolvable by dependent projects @ line 163, column 15
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO] 
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building SAPAutomation 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ SAPAutomation ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\AutomationWorkSpace\SAPAutomation\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ SAPAutomation ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ SAPAutomation ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) @ SAPAutomation ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 35 source files to C:\AutomationWorkSpace\SAPAutomation\target\test-classes
[INFO] 
[INFO] --- maven-surefire-plugin:2.14.1:test (default-test) @ SAPAutomation ---
[INFO] Surefire report directory: C:\AutomationWorkSpace\SAPAutomation\target\surefire-reports

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

Results :

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

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.402 s
[INFO] Finished at: 2015-04-14T17:31:11+00:00
[INFO] Final Memory: 22M/167M
[INFO] ------------------------------------------------------------------------