硒 – TestNG跳过测试 – 为什么?

我正在测试一个带有testng和selenium的web应用程序.测试主要包括打开应用程序的几个页面,并针对每个页面执行一些特定的活动.所以我有一个抽象的基类,它执行“开放页面”测试,并定义了一个抽象方法,用作该测试的数据提供者.然后有几个扩展类为数据提供者提供实现,并且除了基类之外还有几个不同的测试.我有一个testsuite.xml,其中包含所有类,这是我从我的日食中运行的.

问题是当我启动测试执行时,testng在基类中为所有对象运行测试,但系统地跳过扩展类中的每个其他测试.有谁知道为什么?任何信息将非常感谢…

要完成信息,以下是我使用的一些类和xml:

基类:

public abstract class BaseWebAppPageTest {

    @Test(dataProvider="getMenuLink")
    public void testOpen(String menulink){
        GenericPageActions.openPage(TestingContext.getSelenium(), menulink);
    }

    protected abstract String[][] getMenuLink();

}

还有一些扩展类:

TestLanguages:

public class TestLanguages extends BaseWebAppPageTest{

    @Test(dependsOnMethods={"testOpen"}, dataProvider="getCreateData")
    public void testCreateCorrect(String code, String description, String textDirection, String flag){
        Selenium selenium = TestingContext.getSelenium();
        LanguagesManagementActions.create(selenium, code, description, textDirection, flag);
    Assert.assertTrue(selenium.isTextPresent("Successfully created language"));
    }

    @Test(dependsOnMethods={"testCreateCorrect"}, dataProvider="getCreateData")
    public void testFilter(String code, String description, String textDirection, String flag){
        Selenium selenium = TestingContext.getSelenium();
        LanguagesManagementActions.filterTable(selenium, 2, code, 30000);
    Assert.assertTrue(selenium.getXpathCount("xpath=//span[.='"+code+"']").intValue() == 1);
    }

    @Test(dependsOnMethods={"testCreateCorrect"}, dataProvider="getCreateData")
    public void testModify(String code, String description, String textDirection, String flag){
        Selenium selenium = TestingContext.getSelenium();
        LanguagesManagementActions.modify(TestingContext.getSelenium(), code, description, textDirection, flag);
        Assert.assertTrue(selenium.isTextPresent("Successfully updated language"));
    }

    @Override
    @DataProvider
    protected String[][] getMenuLink() {
        return(TestingContext.getDataReader().getTableArray("openviewpage", "MULTILINGUAL_LANGUAGES"));
    }

    @DataProvider
    protected String[][] getCreateData() {
        return(TestingContext.getDataReader().getTableArray("multilingualcreate", "LANGUAGES"));
    }

}

TestTranslations:

public class TestTranslations extends BaseWebAppPageTest{

@Test(dependsOnMethods={"testOpen"}, dataProvider="getCreateData")
public void createCorrect(String code, String targetLanguage, String translation){
    Selenium selenium = TestingContext.getSelenium();
    TranslationsManagementActions.create(selenium, code, targetLanguage, translation);
    Assert.assertTrue(selenium.isTextPresent("Successfully created translation"));
}

@Test(dependsOnMethods={"createCorrect"}, dataProvider="getCreateData")
public void update(String code, String targetLanguage, String translation){
    Selenium selenium = TestingContext.getSelenium();
    TranslationsManagementActions.update(selenium, code, targetLanguage, translation);
    Assert.assertTrue(selenium.isTextPresent("Successfully updated translation"));
}

@Test(dependsOnMethods={"createCorrect"}, dataProvider="getCreateData")
public void filter(String code, String targetLanguage, String translation){
    Selenium selenium = TestingContext.getSelenium();
    TranslationsManagementActions.filterTable(selenium, 2, code, 30000);
    Assert.assertTrue(selenium.isElementPresent("xpath=//span[.='"+translation+"']"));
}

@Override
@DataProvider
protected String[][] getMenuLink() {
    return(TestingContext.getDataReader().getTableArray("openviewpage", "MULTILINGUAL_TRANSLATIONS"));
}

@DataProvider
protected String[][] getCreateData() {
    return(TestingContext.getDataReader().getTableArray("multilingualcreate", "TRANSLATIONS"));
}

}

最后,TestSuite.xml:

<?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
    <suite name="WebAppSuiteTest" parallel="none">
      <parameter name="selenium.host" value="localhost" />
      <parameter name="selenium.port" value="5555" />
      <parameter name="selenium.browser" value="*firefox3 C:\\Documents and Settings\\dgarcia\\Local Settings\\Application Data\\Mozilla Firefox\\firefox.exe" />
      <parameter name="selenium.url" value="http://localhost:8080/standard-webapp-war/home.seam" />
      <parameter name="selenium.timeout" value="1000000" />
      <parameter name="test.data.filepath" value="src\\test\\resources\\datatest_.xls" />

  <test name="standard" preserve-order="true" >
    <classes>
        <class name="com.standard.webapp.common.TestingContext" />      
        <class name="com.standard.webapp.login.TestLogin"/>
        <class name="com.standard.webapp.TestLanguages"/>
        <class name="com.standard.webapp.TestTranslations"/>
        </class>
    </classes>
  </test>
</suite>

输出上没有任何异常也没有任何理由可以跳过这些测试.我不确定你提到的输出,所以我会在这里粘贴生成的“myWebAppTest.xml”的内容和测试结果:

<testsuite hostname="SP2L0044" name="com.sicpa.standard.dms.webapp.selenium.common.BaseWebAppPageTest" tests="14" failures="0" timestamp="4 Mar 2011 08:45:57 GMT" time="27.141" errors="0">
  <testcase name="testLoginLoadHome" time="2.188" classname="com.sicpa.standard.dms.webapp.selenium.login.TestLogin"/>
  <testcase name="testCreateCorrect" time="0.0" classname="com.sicpa.standard.dms.webapp.selenium.multilingual.TestCodes">
    <skipped/>
  </testcase>
  <testcase name="testFilter" time="0.0" classname="com.sicpa.standard.dms.webapp.selenium.multilingual.TestCodes">
    <skipped/>
  </testcase>
  <testcase name="testUpdate" time="0.0" classname="com.sicpa.standard.dms.webapp.selenium.multilingual.TestCodes">
    <skipped/>
  </testcase>
  <testcase name="testView" time="0.0" classname="com.sicpa.standard.dms.webapp.selenium.multilingual.TestCodes">
    <skipped/>
  </testcase>
  <testcase name="testCreateCorrect" time="0.0" classname="com.sicpa.standard.dms.webapp.selenium.multilingual.TestLanguages">
    <skipped/>
  </testcase>
  <testcase name="testFilter" time="0.0" classname="com.sicpa.standard.dms.webapp.selenium.multilingual.TestLanguages">
    <skipped/>
  </testcase>
  <testcase name="testModify" time="0.0" classname="com.sicpa.standard.dms.webapp.selenium.multilingual.TestLanguages">
    <skipped/>
  </testcase>
  <testcase name="createCorrect" time="0.0" classname="com.sicpa.standard.dms.webapp.selenium.multilingual.TestTranslations">
    <skipped/>
  </testcase>
  <testcase name="filter" time="0.0" classname="com.sicpa.standard.dms.webapp.selenium.multilingual.TestTranslations">
    <skipped/>
  </testcase>
  <testcase name="update" time="0.0" classname="com.sicpa.standard.dms.webapp.selenium.multilingual.TestTranslations">
    <skipped/>
  </testcase>
  <testcase name="testOpen" time="2.297" classname="com.sicpa.standard.dms.webapp.selenium.multilingual.TestLanguages"/>
  <testcase name="testOpen" time="12.61" classname="com.sicpa.standard.dms.webapp.selenium.multilingual.TestCodes"/>
  <testcase name="testOpen" time="9.469" classname="com.sicpa.standard.dms.webapp.selenium.multilingual.TestTranslations"/>
</testsuite>
TestNG跳过测试有多种原因,最常见的是你依赖的方法(例如testOpen或createCorrect)以某种方式失败.

我建议将详细级别设置为10并将输出粘贴到此处或testng-users mailing-list上.

相关文章
相关标签/搜索