知道为什么 TestNG 没有运行我的测试吗? 这是类代码(java):
public class main {
@Test
public static void main(String[] args) throws AWTException, InterruptedException
这是 eclipse 上的路径: enter image description here
这是 XML 文件:
<?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="test.main"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
最佳答案
我在这里发布了您的 testng 的演示模板。您只需要参加类(class)并声明 webdriver 即可。 @BeforeMethod
将在启动任何 @Test
之前执行,然后执行 @AfterMethod
希望它会对您有所帮助。
package stackoverflow;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.*;
public class DemoTestNGClass {
public static WebDriver driver;
@BeforeMethod
public void setUp1() throws Exception {
driver= new ChromeDriver();
}
@Test
public void Homepage() throws InterruptedException {
//Your operation
}
@Test
public void ListingPage() throws InterruptedException {
//Your operation
}
@AfterMethod
public void afterresult(){
driver.close();
}
}
关于java - TestNG 未在 eclipse 上运行测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46765098/