testng.xml没有运行类

时间:2015-04-22 01:18:20

标签: java selenium-webdriver testng

我正确地点击我的testng.xml并作为testng Suite运行,但它内部的类没有运行。

这是我的xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="mytestpack" >

 <test name="Firefox Test">

 <parameter name="browser" value="Firefox"/> 

 <classes>

 <class name="mytestpack.MyTestClass" />

 </classes>

 </test>


</suite>

这是MyTestClass代码:

package testing_pack;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

public class MyTestClass {

    private static WebDriver driver;

    @Parameters({"browser"})
    @BeforeTest
    public void setup(String browser) {

         System.out.println(browser);

              // If the browser is Firefox, then do this

              if(browser.equalsIgnoreCase("firefox")) {

                  driver = new FirefoxDriver();

              // If browser is IE, then do this   

              }
         }


    @Test
    public static void test() {

          driver.get("http://only-testing-blog.blogspot.in");
          String i = driver.getCurrentUrl();
          System.out.println(i);

    }
    @AfterTest
    public void teardown() {
        driver.close();
    }
    }

该课程完全可以自己运行。不明白为什么testng没有运行它。它不会抛出它显示的任何错误:

[TestNG] Running:
  C:\Users\Laptops\Desktop\eclipse\workspace\testproject\src\mytestpack\testng.xml


===============================================
mytestpack
Total tests run: 0, Failures: 0, Skips: 0
===============================================

由于

1 个答案:

答案 0 :(得分:1)

testng.xml中的套件名称从mytestpack更改为testing_pack。班级MyTestClass属于不同的包裹。