如何在我的 testng.xml 配置文件中使用组 'depends-on'?

How do I use groups 'depends-on' in my testng.xml config file?

我正在使用 IntelliJ-IDEA 14.x 和 TestNG 6.8.17,但是当我尝试使用 depends-on 属性时,出现以下错误:

Element dependencies is not allowed here

这是我的 testng.xml 配置文件:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="My Regression Suite" parallel="classes" thread-count="15">
    <test name="My suite">
        <groups>
            <dependencies>
                <group name="c" depends-on="a  b" />
                <group name="z" depends-on="c" />
            </dependencies>
        </groups>
    </test>
</suite>

可能是哪里出了问题??有什么调试方法吗?我直接从 TestNG 文档站点复制了这段代码。

我在 6.8.17 中也没有遇到上述错误(我使用的是 eclipse)。 但, 无论何时使用组,您都需要指定哪些测试也需要包含在测试中。只是团体是行不通的。

例如

<test name="DOD Check">
        <groups>
            <dependencies>
                <group name="c" depends-on="a  b" />
                <group name="z" depends-on="c" />

            </dependencies>
        </groups>
        <classes>
            <class name="testngtests.TestDependsGroups"></class>
        </classes>
    </test>

问题似乎是由通过 IntelliJ 的 TestNG 插件 (TetsNG-J) 提供的不同版本的 DTD 引起的。我不知道为什么这样做,因为 DTD 应该从 TestNG 服务器下载。 IntelliJ 实际上确实会联系 TestNG 服务器以获取 DTD,但仍会导入在位于 JetBrains\IntelliJ IDEA 14.1.4\plugins\testng\lib 文件夹中的插件 JAR 中找到的 DTD。 虽然不是一个明确的解决方案,但您可以将 JAR 中找到的 DTD 替换为 http://testng.org/testng-1.0.dtd 中可用的 DTD。这有效地消除了错误消息,但在 TestNG-J 插件的未来版本中可能会再次出现该问题。