我有一个包含 10 多个课程的 testNG 套件。当我将 testNG.xml 作为套件启动时,浏览器(ff)在进入第二类之前没有关闭,我曾经在第二类中打开浏览器并在每个类中关闭它。我已经测试过它只给一个浏览器关闭的类。请检查以下代码以获取@AfterTest
@BeforeClass(alwaysRun = true)
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl = "http://www.example.com";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test(priority=0)
public void testActivityMasterDBCheck() throws Exception {
--------------------
--------------------
@AfterTest
public void tearDown() throws Exception {
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString))
{
fail(verificationErrorString);
}
}
and XML is
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite">
<test name="Test">
<classes>
<class name="Admin.ManagePackagesDBCheck"/>
<class name="Reports.ActiveStatusReportDBCheck"/>
----------
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->