首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >testng.xml不运行类

testng.xml不运行类
EN

Stack Overflow用户
提问于 2015-04-22 01:18:20
回答 1查看 5.1K关注 0票数 0

我正在右键单击我的testng.xml并以testng套件的形式运行,但是它中的类没有运行。

这是我的xml文件:

代码语言:javascript
复制
<?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代码:

代码语言:javascript
复制
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不运行它。它不会抛出任何只显示的错误:

代码语言:javascript
复制
[TestNG] Running:
  C:\Users\Laptops\Desktop\eclipse\workspace\testproject\src\mytestpack\testng.xml


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

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-04-22 05:14:04

testng.xml中的套件名从mytestpack更改为testing_pack。类MyTestClass在不同的包下。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29786051

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档