TestNg执行警告POM.xml。

huangapple go评论80阅读模式
英文:

TestNg Execution is giving warning for POM.xml

问题

在执行TestNG运行器类时,我在控制台上看到以下消息,但TestNG既没有启动任何内容,也没有显示任何失败的内容。

[RemoteTestNG] detected TestNG version 6.14.3 [TestNGContentHandler] [WARN] It is strongly recommended to add "<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >" at the top of your file, otherwise TestNG may fail or not work as expected.

我尝试了多种方法,如从Eclipse的“安装软件”中升级TestNG,但都没有成功。以下是我的pom.xml文件,我还尝试将TestNG降级,但也没有成功。

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
          http://maven.apache.org/xsd/maven- 
          4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>io.testing.tables</groupId>
    <artifactId>datatables</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
    </properties>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>io.cucumber</groupId>
                <artifactId>cucumber-bom</artifactId>
                <version>7.11.2</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.junit</groupId>
                <artifactId>junit-bom</artifactId>
                <version>5.8.2</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <!-- 其他依赖 -->
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.14.3</version>
            <scope>test</scope>
        </dependency>
        <!-- 其他依赖 -->
    </dependencies>
    <build>
        <plugins>
            <!-- Maven插件配置 -->
        </plugins>
    </build>
</project>

请注意以上是我使用的POM.xml文件。

英文:

While executing TestNG runner class I am getting below message on console and TestNG is not launching anything, neither it is showing anything failed.

[RemoteTestNG] detected TestNG version 6.14.3 [TestNGContentHandler] [WARN] It is strongly recommended to add &quot;&lt;!DOCTYPE suite SYSTEM &quot;http://testng.org/testng-1.0.dtd&quot; &gt;&quot; at the top of your file, otherwise TestNG may fail or not work as expected.

I have tried multiple things like upgrade TestNG from Install Software from eclipse but it didn't work. Below is my pom.xml Also tried to degrade the the TestNG but it didn't work.
Please see the below POM.xml I am using.

    &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;project xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot;
xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven- 
4.0.0.xsd&quot;&gt;
&lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
&lt;groupId&gt;io.testing.tables&lt;/groupId&gt;
&lt;artifactId&gt;datatables&lt;/artifactId&gt;
&lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
&lt;packaging&gt;jar&lt;/packaging&gt;
&lt;properties&gt;
&lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
&lt;maven.compiler.source&gt;11&lt;/maven.compiler.source&gt;
&lt;maven.compiler.target&gt;11&lt;/maven.compiler.target&gt;
&lt;/properties&gt;
&lt;dependencyManagement&gt;
&lt;dependencies&gt;
&lt;dependency&gt;
&lt;groupId&gt;io.cucumber&lt;/groupId&gt;
&lt;artifactId&gt;cucumber-bom&lt;/artifactId&gt;
&lt;version&gt;7.11.2&lt;/version&gt;
&lt;type&gt;pom&lt;/type&gt;
&lt;scope&gt;import&lt;/scope&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.junit&lt;/groupId&gt;
&lt;artifactId&gt;junit-bom&lt;/artifactId&gt;
&lt;version&gt;5.8.2&lt;/version&gt;
&lt;type&gt;pom&lt;/type&gt;
&lt;scope&gt;import&lt;/scope&gt;
&lt;/dependency&gt;
&lt;/dependencies&gt;
&lt;/dependencyManagement&gt;
&lt;dependencies&gt;
&lt;dependency&gt;
&lt;groupId&gt;io.cucumber&lt;/groupId&gt;
&lt;artifactId&gt;cucumber-java&lt;/artifactId&gt;
&lt;scope&gt;test&lt;/scope&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;io.cucumber&lt;/groupId&gt;
&lt;artifactId&gt;cucumber-junit-platform-engine&lt;/artifactId&gt;
&lt;scope&gt;test&lt;/scope&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.junit.platform&lt;/groupId&gt;
&lt;artifactId&gt;junit-platform-suite&lt;/artifactId&gt;
&lt;scope&gt;test&lt;/scope&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.junit.jupiter&lt;/groupId&gt;
&lt;artifactId&gt;junit-jupiter&lt;/artifactId&gt;
&lt;scope&gt;test&lt;/scope&gt;
&lt;/dependency&gt;
&lt;!-- https://mvnrepository.com/artifact/org.testng/testng --&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.testng&lt;/groupId&gt;
&lt;artifactId&gt;testng&lt;/artifactId&gt;
&lt;version&gt;6.14.3&lt;/version&gt;
&lt;scope&gt;test&lt;/scope&gt;
&lt;/dependency&gt;
&lt;!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-testng --&gt;
&lt;dependency&gt;
&lt;groupId&gt;io.cucumber&lt;/groupId&gt;
&lt;artifactId&gt;cucumber-testng&lt;/artifactId&gt;
&lt;/dependency&gt;
&lt;!-- https://mvnrepository.com/artifact/org.apache.poi/poi --&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.apache.poi&lt;/groupId&gt;
&lt;artifactId&gt;poi&lt;/artifactId&gt;
&lt;version&gt;5.2.2&lt;/version&gt;
&lt;/dependency&gt;
&lt;!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml --&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.apache.poi&lt;/groupId&gt;
&lt;artifactId&gt;poi-ooxml&lt;/artifactId&gt;
&lt;version&gt;5.2.2&lt;/version&gt;
&lt;/dependency&gt;
&lt;!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core --&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.apache.logging.log4j&lt;/groupId&gt;
&lt;artifactId&gt;log4j-core&lt;/artifactId&gt;
&lt;version&gt;2.17.2&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.apache.commons&lt;/groupId&gt;
&lt;artifactId&gt;commons-csv&lt;/artifactId&gt;
&lt;version&gt;1.9.0&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.seleniumhq.selenium&lt;/groupId&gt;
&lt;artifactId&gt;selenium-java&lt;/artifactId&gt;
&lt;version&gt;3.141.59&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.apache.maven.surefire&lt;/groupId&gt;
&lt;artifactId&gt;surefire-junit47&lt;/artifactId&gt;
&lt;version&gt;2.19.1&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.seleniumhq.selenium&lt;/groupId&gt;
&lt;artifactId&gt;selenium-server&lt;/artifactId&gt;
&lt;version&gt;3.3.1&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;com.beust&lt;/groupId&gt;
&lt;artifactId&gt;jcommander&lt;/artifactId&gt;
&lt;version&gt;1.72&lt;/version&gt;
&lt;/dependency&gt;
&lt;!-- https://mvnrepository.com/artifact/org.apache.commons/commons-collections4 --&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.apache.commons&lt;/groupId&gt;
&lt;artifactId&gt;commons-collections4&lt;/artifactId&gt;
&lt;version&gt;4.4&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;io.github.bonigarcia&lt;/groupId&gt;
&lt;artifactId&gt;webdrivermanager&lt;/artifactId&gt;
&lt;version&gt;4.2.2&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;info.cukes&lt;/groupId&gt;
&lt;artifactId&gt;cucumber-testng&lt;/artifactId&gt;
&lt;version&gt;1.2.5&lt;/version&gt;
&lt;/dependency&gt;   
&lt;/dependencies&gt;
&lt;build&gt;
&lt;plugins&gt;
&lt;plugin&gt;
&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
&lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
&lt;version&gt;3.10.1&lt;/version&gt;
&lt;configuration&gt;
&lt;encoding&gt;UTF-8&lt;/encoding&gt;
&lt;/configuration&gt;
&lt;/plugin&gt;
&lt;plugin&gt;
&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
&lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
&lt;version&gt;3.0.0-M6&lt;/version&gt;
&lt;/plugin&gt;
&lt;/plugins&gt;
&lt;/build&gt;

答案1

得分: 1

在你的TestNG XML文件顶部添加DOCTYPE声明。该声明指定了应该使用的TestNG DTD(文档类型定义)版本。在你的XML文件的最开始添加以下行:

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">

在你的POM.xml文件中升级TestNG版本,以支持DOCTYPE声明中提到的TestNG DTD。

<dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>7.3.0</version>
    <scope>test</scope>
</dependency>
英文:

Add the DOCTYPE declaration at the top of your TestNG XML file. This declaration specifies the TestNG DTD (Document Type Definition) version that should be used. Add the following line at the very beginning of your XML file:

&lt;!DOCTYPE suite SYSTEM &quot;http://testng.org/testng-1.0.dtd&quot;&gt;

Upgrade the TestNG version in your POM.xml file to a version that supports the TestNG DTD mentioned in the DOCTYPE declaration.

&lt;dependency&gt;
&lt;groupId&gt;org.testng&lt;/groupId&gt;
&lt;artifactId&gt;testng&lt;/artifactId&gt;
&lt;version&gt;7.3.0&lt;/version&gt;
&lt;scope&gt;test&lt;/scope&gt;
&lt;/dependency&gt;

答案2

得分: 0


解决方案

确保:

<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>7.8.0</version>
    <scope>test</scope>
</dependency>
  • testng.xml文件顶部包含以下DOCTYPE声明:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
英文:

TestNG v6.14.3 released on Apr 09, 2018 is old and ancient now.


Solution

Ensure that:

  • TestNG is upgraded to recent release of TestNG v7.8.0:

    &lt;!-- https://mvnrepository.com/artifact/org.testng/testng --&gt;
    &lt;dependency&gt;
    &lt;groupId&gt;org.testng&lt;/groupId&gt;
    &lt;artifactId&gt;testng&lt;/artifactId&gt;
    &lt;version&gt;7.8.0&lt;/version&gt;
    &lt;scope&gt;test&lt;/scope&gt;
    &lt;/dependency&gt;
    
  • testng.xml contains the DOCTYPE declaration at the top as:

    &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
    &lt;!DOCTYPE suite SYSTEM &quot;https://testng.org/testng-1.0.dtd&quot;&gt;
    

huangapple
  • 本文由 发表于 2023年7月12日 22:23:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/76671621.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定