org.testng.TestNGException:找不到任何空闲节点:[DynamicGraph

时间:2014-04-01 11:38:37

标签: automation testng

我在testng中使用了两个相同类的方法,但它不允许我这样......它给出异常

  

org.testng.TestNGException:找不到任何空闲节点:[DynamicGraph

我的testng文件是

<test name="User Data" preserve-order="true">
<classes>
    <class name="LoginTest">
        <methods>
            <include name="Login" />         
        </methods>
    </class>
<class name="xtr.chaut.test.PatientProfileTest">
      <methods>
            <include name="openPatientProfile"></include>
            <include name="checkUserData"></include>
       </methods>
</class>
  <class name="xtr.chaut.test.Login">
      <methods>
          <include name="logout"></include>
      </methods>
  </class>
</classes> 

这里的登录和注销方法来自同一个类

请给我任何解决方案

提前致谢

5 个答案:

答案 0 :(得分:4)

似乎每个类只能在列表中声明一次,即使每个声明中包含不同的方法,否则您将看到此错误消息:(使用最新的TestNG 6.8.8。我能够得到这个使用@Test(priority =#),并对每种测试方法都有特定的优先级。请参阅http://testng.org/doc/documentation-main.html#annotations

我的用例:实体的crud测试。每个实体都有自己的测试类,有4个方法(所以我可以单独测试单个实体CRUD),但我也想运行整个套件(由于完整性限制和不同生成的ID密钥会失败,除非它们在完全正确的顺序)。

Getting org.testng.TestNGException: No free nodes found in:[DynamicGraph Exception询问了同样的问题。

答案 1 :(得分:0)

当我将数字设置为零以获得优先级时,我得到了同样的错误:

@Test(groups =“setup”,priority = -1

当我设置优先自然数时,例如

@Test(groups =“setup”,priority = 1

一切正常。

答案 2 :(得分:0)

删除测试用例的否定优先级值。它对我有用。

答案 3 :(得分:0)

我通过添加parallel =“ true”修复了问题,下面是代码

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Sanity Testing" parallel="true">
  <test name="VerifyTitles">
    <classes>
      <class name="WebDriver.VerifyTitles"/>
      <class name="WebDriver.VerifyTitles2"/>
    </classes>
  </test> <!-- Test -->
</suite> <!-- Suite -->

答案 4 :(得分:0)

我也通过定义一行依赖项并用优先级数字标记来得到这个错误。但是后来忘记了依赖于其他方法的一种方法的优先级标签。

例如在测试类中:

@Test
public void test1() throws Exception{ ...

@Test( priority=2 )
public void test2() throws Exception{ ...

@Test( priority=2, dependsOnMethods={"test2"})
public void test3() throws Exception{ ...

@Test( dependsOnMethods={"test3"})
public void test4() throws Exception{ ...

test4 会导致异常,因为它依赖于 test3,但没有优先级。