繁体   English   中英

TestNG.XML 未执行。当通过 maven 运行时 -mvn 测试 - 即使在 POM.Z350FZ6093D396318 中正确配置后也是如此

[英]TestNG.XML not executing.when run via maven -mvn test - even after proper configurations in POM.XML


这是我在 StackOverflow 上的第一个问题,如果问题不准确,请见谅。
我创建了一个 maven 项目。 尝试通过 maven 运行 TestNG.XML 但同样不起作用。 低于 output

[INFO] Scanning for projects...
[INFO]
[INFO] --------------------< MavenTestDemo:MavenTestDemo >---------------------
[INFO] Building MavenTestDemo 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MavenTestDemo ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ MavenTestDemo ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ MavenTestDemo ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ MavenTestDemo ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 3 source files to C:\Users\sneha\eclipse-workspace\MavenTestDemo\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:3.0.0-M4:test (default-test) @ MavenTestDemo ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.458 s
[INFO] Finished at: 2020-04-07T18:26:56+05:30
[INFO] ------------------------------------------------------------------------

测试用例没有执行,只是显示构建成功。 但是当我尝试使用 TestNG 套件运行 TestNG.xml 套件时,同样运行正常。
当我将 class 名称命名为“Demo1Test.java”时,代码会按预期运行,但我们始终不能给出以 Test 结尾的名称。

请在下面找到我的 TestNG.xml 和 POM.xml 文件:

TestNG.xml

<?xml version="1.0" encoding="UTF-8"?>
<suite name="maven test">
<test name="TestNG testing">
<packages>
<package name="com.qa.tests.*"/>
</packages>
</test>
</suite>

POM.xml

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>MavenTestDemo</groupId>
  <artifactId>MavenTestDemo</artifactId>
  <version>0.0.1-SNAPSHOT</version>
<build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.0.0-M4</version>

        <configuration>
        <suiteXMLFiles>
       <classpathScope>test</classpathScope>
                <suiteXMLFile>src/test/resources/TestNG.xml</suiteXMLFile>
                </suiteXMLFiles>
        </configuration>
      </plugin>
    </plugins>
  </build>  
<dependencies>
<dependency>
  <groupId>org.apache.maven.surefire</groupId>
  <artifactId>surefire-testng</artifactId>
  <version>3.0.0-M4</version>
</dependency>
  <dependency>
  <groupId>org.testng</groupId>
  <artifactId>testng</artifactId>
  <version>6.8</version>
  <scope>test</scope>

  </dependency>

  <dependency>
  <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.141.59</version>
  </dependency>

  </dependencies>

</project>

你能给我提供这些方面的见解吗?

我没有看到 Maven 编译器插件。

   <!-- Compiler plugin configures the java version to be usedfor compiling the code --> 

<plugin> 
    <artifactId>maven-compiler-plugin</artifactId> 
    <configuration> 
    <source>1.6</source> 
    <target>1.6</target>
    </configuration> 
    </plugin>

我面临同样的问题。 任何人都可以帮助解决这个问题。

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM