1

パッケージに 3 つのテスト クラスがあります。最初の構成:

public class PageVisibilityConfig {
WebDriver driver;

@BeforeSuite
public void beforeSuite() {
    DOMConfigurator.configure("log4j.xml");
    Log.startTestCase("Page Visibility Suite");
    Log.info(Thread.currentThread().getStackTrace()[1].getMethodName());
    driver = BrowserFactory.getBrowser("Firefox");

}

@AfterSuite(enabled = true)
public void afterSuite() {
    Log.info(Thread.currentThread().getStackTrace()[1].getMethodName());
    BrowserFactory.closeAllDriver();
    Log.endTestCase("Page Visibility Suite");
}

@AfterGroups(groups = { "admin", "user" })
public void afterGroupLogOut() {
    Log.info(Thread.currentThread().getStackTrace()[1].getMethodName());
    UserMenu usermenu = PageFactory.initElements(driver, UserMenu.class);
    usermenu.activeteUserMenu();
    usermenu.logout();
}
}

最初の実際のテスト クラス:

public class PageVisibilityAdmin {
WebDriver driver;

@BeforeClass(groups = { "admin" }, enabled = true)
public void beforeClassLogin() {
    driver = BrowserFactory.getBrowser("Firefox");

    Log.startTestCase("Page Visibility Admin test cases");
    Log.info(Thread.currentThread().getStackTrace()[1].getMethodName());

    LogIn login = PageFactory.initElements(driver, LogIn.class);
    login.signupLogin();
    login.loginViaCredentials();

    UserMenu usermenu = PageFactory.initElements(driver, UserMenu.class);
    usermenu.activeteUserMenu();

    Assert.assertTrue(usermenu.isAdmin());
}

@DataProvider(name = "visibility_admin")
public static String[][] providedData() {
    return com.resources.SQLConForDataProvider
            .executeQuery("SELECT url FROM cdb_1cc755a513.visibility where admin='1' limit 1");
}

@Test(dataProvider = "visibility_admin", groups = { "admin" }, enabled = true)
public void adminRun(String url) {
    Log.info(Thread.currentThread().getStackTrace()[1].getMethodName());
    Log.info("Try " + Util.SUT + url);

    driver.get(Util.SUT + url);

    Log.info("Actual page " + driver.getCurrentUrl());

    Assert.assertEquals(driver.getCurrentUrl(), Util.SUT + url);
    Assert.assertFalse(driver.getTitle().toLowerCase().contains("not found"));
    Assert.assertFalse(driver.getTitle().toLowerCase().contains("login"));
    Assert.assertFalse(driver.getTitle().toLowerCase().contains("error"));
}

}

そして問題の3番目:

public class PageVisibilityUser {
WebDriver driver;

@BeforeClass(groups = { "user" }, enabled = true)
public void beforeGroupsLogin() {
    driver = BrowserFactory.getBrowser("Firefox");

    Log.startTestCase("Page Visibility User test cases");
    Log.info(Thread.currentThread().getStackTrace()[1].getMethodName());

    LogIn login = PageFactory.initElements(driver, LogIn.class);
    login.signupLogin();
    login.loginViaFacebook();

    UserMenu usermenu = PageFactory.initElements(driver, UserMenu.class);
    usermenu.activeteUserMenu();

    Assert.assertFalse(usermenu.isAdmin());
}

@DataProvider(name = "visibility_user")
public static String[][] providedData() {
    return com.resources.SQLConForDataProvider
            .executeQuery("SELECT url FROM cdb_1cc755a513.visibility where not_added_user='1' limit 1");
}

@Test(dataProvider = "visibility_user", groups = { "user" }, enabled = true)
public void userRun(String url) {
    Log.info(Thread.currentThread().getStackTrace()[1].getMethodName());
    Log.info("Try " + Util.SUT + url);

    driver.get(Util.SUT + url);

    Log.info("Actual page " + driver.getCurrentUrl());

    Assert.assertEquals(driver.getCurrentUrl(), Util.SUT + url);
    Assert.assertFalse(driver.getTitle().toLowerCase().contains("not found"));
    Assert.assertFalse(driver.getTitle().toLowerCase().contains("login"));
    Assert.assertFalse(driver.getTitle().toLowerCase().contains("error"));

}
}

基本的に、URL がさまざまな役割で利用可能かどうかを確認しています。私の問題は次のとおりです。これらのクラスをスイートまたはパッケージとして実行した場合、最後のクラスはSQL結果セットの「余分な行」(null)で失敗します。構成クラスと最後のクラスのみを実行すると、エラーなしで実行されます。そして例外(これは奇妙です):

TestSuite java.sql.SQLException の実行: 結果セットの終了後、com.mysql.jdbc.SQLError.createSQLException(SQLError.java:998) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:937) at com. mysql.jdbc.SQLError.createSQLException(SQLError.java:926) com.mysql.jdbc.SQLError.createSQLException(SQLError.java:872) com.mysql.jdbc.ResultSetImpl.checkRowPos(ResultSetImpl.java:787) com .mysql.jdbc.ResultSetImpl.getStringInternal(ResultSetImpl.java:5244) com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5167) com.resources.SQLConForDataProvider.executeQuery(SQLConForDataProvider.java:47) com. pageVisibility.PageVisibilityUser.providedData(PageVisibilityUser.java:39) at sun.reflect.NativeMethodAccessorImpl.invoke0(ネイティブ メソッド) at sun.reflect.NativeMethodAccessorImpl.呼び出し (NativeMethodAccessorImpl.java:57)

4

0 に答える 0