简体   繁体   中英

TestNG not running test on eclipse

Any idea why TestNG is not running my test? this is the class code(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 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. @BeforeMethod will execute before start any @Test then @AfterMethod Hope it will help you.

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.
  2. If not install latest from Help => Eclipse Marketplace.
  3. Restart eclipse.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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