我遇到了无法理解的testNg异常。我已经用Google搜索错误原因,但是那里什么也没有。我在同一标签的testNg类中运行两个类。它给我“在以下位置找不到免费节点:” [)错误。这是我的两个TestClasses。 这是名为 loginPageTest
的第一类@BeforeMethod
public void setup() throws Exception {
intialization();
login = new login();
}
@Test(priority=1,groups="login")
public void titleVerification() {
String validateTitleMethod = login.validateTitleMethod();
Assert.assertEquals(validateTitleMethod, "OraneHRM");
}
@Test(priority=2,groups="login")
public void logoVerification() {
boolean validatePagelogo = login.validatePagelogo();
Assert.assertTrue(validatePagelogo);
}
@Test(priority=3,groups="login")
public void loginTest() {
login.loginMethod();
}
@AfterMethod
public void teardown() {
driver.quit();
}
这是另一个名为 HomePageTest
的测试类 public class HomePageTest extends TestBase {
private static login login;
private static Home home;
@BeforeMethod(alwaysRun=true)
public void setup() throws Exception {
intialization();
login = new login();
home = login.loginMethod();
}
@Test(priority=1,groups="Home")
public void ValidateHomeUserTest() {
home.HomePageUserValidate();
}
@Test(priority=2,groups="Home")
public void ValidateMenuTest() throws InterruptedException {
Assert.assertTrue(home.ValidateMenu("Admin"),"Menu is not present");
}
//dependsOnMethods= {"ValidateMenuTest"}
@Test(dependsOnMethods= {"ValidateMenuTest"})
public void clickOnAdminTest() {
home.ClickOnAdmin();
}
@AfterMethod
public void teardown() {
driver.quit();
}
}
TestNg Xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Orange CRM Tests" >
<test name="Orange CRM Tests">
<classes>
<class name="com.crm.qa.testcases.loginPageTest" />
<class name="com.crm.qa.testcases.HomePageTest" />
</classes>
</test> <!-- Orange CRM Tests -->
</suite> <!-- Orange CRM Tests -->
错误:
[RemoteTestNG] detected TestNG version 6.14.3
org.testng.TestNGException:
No free nodes found in:[DynamicGraph
Ready:[loginPageTest.loginTest()[pri:3, instance:com.crm.qa.testcases.loginPageTest@4883b407], loginPageTest.logoVerification()[pri:2, instance:com.crm.qa.testcases.loginPageTest@4883b407], loginPageTest.titleVerification()[pri:1, instance:com.crm.qa.testcases.loginPageTest@4883b407], HomePageTest.ValidateMenuTest()[pri:2, instance:com.crm.qa.testcases.HomePageTest@7d9d1a19], HomePageTest.clickOnAdminTest()[pri:0, instance:com.crm.qa.testcases.HomePageTest@7d9d1a19], HomePageTest.ValidateHomeUserTest()[pri:1, instance:com.crm.qa.testcases.HomePageTest@7d9d1a19]]
Running:[]
Finished:[]
Edges:
HomePageTest.clickOnAdminTest()[pri:0, instance:com.crm.qa.testcases.HomePageTest@7d9d1a19]
HomePageTest.ValidateMenuTest()[pri:2, instance:com.crm.qa.testcases.HomePageTest@7d9d1a19]
loginPageTest.logoVerification()[pri:2, instance:com.crm.qa.testcases.loginPageTest@4883b407]
loginPageTest.loginTest()[pri:3, instance:com.crm.qa.testcases.loginPageTest@4883b407]
HomePageTest.ValidateMenuTest()[pri:2, instance:com.crm.qa.testcases.HomePageTest@7d9d1a19]
loginPageTest.titleVerification()[pri:1, instance:com.crm.qa.testcases.loginPageTest@4883b407]
HomePageTest.ValidateHomeUserTest()[pri:1, instance:com.crm.qa.testcases.HomePageTest@7d9d1a19]
loginPageTest.logoVerification()[pri:2, instance:com.crm.qa.testcases.loginPageTest@4883b407]
loginPageTest.titleVerification()[pri:1, instance:com.crm.qa.testcases.loginPageTest@4883b407]
HomePageTest.ValidateHomeUserTest()[pri:1, instance:com.crm.qa.testcases.HomePageTest@7d9d1a19]
HomePageTest.clickOnAdminTest()[pri:0, instance:com.crm.qa.testcases.HomePageTest@7d9d1a19]
loginPageTest.loginTest()[pri:3, instance:com.crm.qa.testcases.loginPageTest@4883b407]
loginPageTest.titleVerification()[pri:1, instance:com.crm.qa.testcases.loginPageTest@4883b407]
loginPageTest.logoVerification()[pri:2, instance:com.crm.qa.testcases.loginPageTest@4883b407]
loginPageTest.titleVerification()[pri:1, instance:com.crm.qa.testcases.loginPageTest@4883b407]
HomePageTest.ValidateHomeUserTest()[pri:1, instance:com.crm.qa.testcases.HomePageTest@7d9d1a19]
loginPageTest.loginTest()[pri:3, instance:com.crm.qa.testcases.loginPageTest@4883b407]
loginPageTest.logoVerification()[pri:2, instance:com.crm.qa.testcases.loginPageTest@4883b407]
HomePageTest.ValidateMenuTest()[pri:2, instance:com.crm.qa.testcases.HomePageTest@7d9d1a19]
loginPageTest.titleVerification()[pri:1, instance:com.crm.qa.testcases.loginPageTest@4883b407]
HomePageTest.clickOnAdminTest()[pri:0, instance:com.crm.qa.testcases.HomePageTest@7d9d1a19]
]
at org.testng.TestRunner.privateRun(TestRunner.java:642)
at org.testng.TestRunner.run(TestRunner.java:505)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
at org.testng.SuiteRunner.run(SuiteRunner.java:364)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1137)
at org.testng.TestNG.runSuites(TestNG.java:1049)
at org.testng.TestNG.run(TestNG.java:1017)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
当我同时在XML中运行两个测试类时遇到错误,但是在两种情况下它可以正常工作: 1.当我通过XML运行一次测试(一次)时,它可以正常工作。 2.当我在 HomePageTest.clickOnAdminTest()中添加“ priority = 3” 批注并以XML一起运行两个测试时,也可以正常工作。
HomePageTest.clickOnAdminTest()取决于HomaPageTest类中的另一种方法,那为什么还要在 HomePageTest.clickOnAdminTest()中提到优先级呢?并且如果必须提到优先级,那么当我分别运行单个HomePageTest时,如何在不添加优先级的情况下工作?
请帮助理解这一点。