简体   繁体   English

TestNG未在Eclipse上运行测试

[英]TestNG not running test on eclipse

Any idea why TestNG is not running my test? 知道为什么TestNG没有运行我的测试吗? this is the class code(java): 这是类代码(java):

public class main {
@Test
public static void main(String[] args) throws AWTException, InterruptedException 

this is the path on eclipse: enter image description here 这是蚀的路径: 在此处输入图像描述

and this is the XML file: 这是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 -->

I am Posted here a demo template for Your testng.You just need to take a class and declear webdriver. 我已在此处发布了testng的演示模板。您只需要上一堂课并清除webdriver。 @BeforeMethod will execute before start any @Test then @AfterMethod Hope it will help you. @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();
        }

    }
  1. Check whether Eclipse plugin for TestNG is present on your machine. 检查您的机器上是否存在用于TestNG Eclipse插件。
  2. If not install latest from Help => Eclipse Marketplace. 如果未安装,请从Help => Eclipse Marketplace安装最新版本。
  3. Restart eclipse. 重新开始蚀。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM