Python中文网

一个关于 编程问题的解答网站.

有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java一些测试没有得到执行,但如果单独运行,执行得很好

我试图通过testng.xml文件运行两个类。总共有5到6个方法需要运行。但是当我使用testng.xml执行时,总共只有3个测试在运行。但当我管理个人课程时,它运行得非常好

类别:SmartRetrievePageTest。爪哇

package tests;

import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import base.BrowserFactory;
import helper.DriverOperations;
import pages.HomePage;
import pages.LoginPage;
import pages.SmartRetrievePage;
import testbase.TestBase;

public class SmartRetrievePageTest extends TestBase {


    LoginPage loginPage;
    HomePage homePage;
    SmartRetrievePage smartretrievePage;

    public SmartRetrievePageTest()
    {
        super();
    }

    @BeforeMethod(groups = { "SmartRetrieve" })
    public void setUp() throws Exception {
        BrowserFactory.launchApplication(prop.getProperty("Browser"), prop.getProperty("URL"));
        loginPage = new LoginPage();
        smartretrievePage = new SmartRetrievePage();
        homePage =  loginPage.login(prop.getProperty("UserName"),prop.getProperty("Password")); 
        Thread.sleep(2000);
        //smartDepositPage = homePage.clickDepositLink();
        DriverOperations.expandTopNavigationMenuAndPerformNavitation("Select application", "SmartRetrieve");
        Thread.sleep(3000);

    }

    @Test(priority = 1, groups = { "SmartRetrieve" })
    public void QuickSearch() throws Throwable {
        smartretrievePage.QuickSearching(prop.getProperty("QuickSearchKeyword"));
        //smartretrievePae.QuickSearching("adm");
        Thread.sleep(3000);

    }
    @Test(priority = 2, groups = { "SmartRetrieve" }, alwaysRun=true)
    public void AdvSearch() throws Throwable {
        smartretrievePage.AdvanceSearching(prop.getProperty("AdvanceSearchkeyword"));
        Thread.sleep(3000);


    }
    @Test(priority = 3, groups = { "SmartRetrieve" }, alwaysRun=true)
    public void SimpleSaveSearch() throws Throwable {
        smartretrievePage.sipmleSaveSearch(prop.getProperty("AdvanceSearchkeyword"),prop.getProperty("SearchName"));
        Thread.sleep(3000);

    }


    @AfterMethod(groups = { "SmartRetrieve" })
    public void tearDown() throws Exception{
        DriverOperations.logOut();
    }

}

类别:SmartRetrievePage。爪哇

package pages;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;

import base.BrowserFactory;
import helper.DriverOperations;

public class SmartRetrievePage extends BrowserFactory{


    //here are findElemtnts 


    public SmartRetrievePage()
    {
        PageFactory.initElements(driver, this);
    }



    public void QuickSearching(String keyword) throws InterruptedException
    {
        DriverOperations.clearFieldAndEnterStringData(quickSearch, keyword);
        DriverOperations.clickWhenElementIsClickable(ShowResultQuickSearch);
        Thread.sleep(3000);
        //return new SmartRetrievePage();
    }

    public void AdvanceSearching(String SearchValue) throws InterruptedException
    {
        DriverOperations.selectDropdownOptionByVisibleText(RetrieveDocumentType, "inv_header");
        DriverOperations.clearFieldAndEnterStringData(Searchvalue, SearchValue);
        DriverOperations.clickWhenElementIsClickable(ShowResult);
        Thread.sleep(3000);


    }

    public void sipmleSaveSearch(String SearchValue, String searchName) throws InterruptedException
    {
        DriverOperations.selectDropdownOptionByVisibleText(RetrieveDocumentType, "inv_header");
        DriverOperations.clearFieldAndEnterStringData(Searchvalue, SearchValue);
        DriverOperations.clickWhenElementIsClickable(SaveSearchButton);
        DriverOperations.clearFieldAndEnterStringData(SearchName, searchName);
        DriverOperations.clickWhenElementIsClickable(SaveSearch);
        Thread.sleep(3000);
    }

}

同样地,也有SmartRetentionPageTest.javaSmartRetentionPage.java类。下面是testng.xml文件

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

<suite name="Smoke testSuite" >
    <test name="Smoke test" > 

        <groups>

            <run>

                <include name="SmartRetrieve" />
                <include name="SmartRetention" /> 
            </run>
        </groups>

        <classes>

            <class name="tests.SmartRetrievePageTest" />
            <class name="tests.SmartRetentionPageTest" /> 
        </classes>

    </test>
</suite>

共 (0) 个答案