2016-11-01 11 views
0

のApache Antのbuild.xmlの'に失敗>による '@BeforeClass'のApache Antのbuild.xmlの '>による '@BeforeClass'

いけないに失敗し、私のビルドファイルは、私のテストを実行していない理由を知っていますか?

コンソール例外: enter image description here

ビルドファイル:

<project name="Sample Ant build" default="testng-execution" basedir="C:/Users/gpb7642/Desktop/PhAutomationFramework/PhFramework"> 
<!-- ========== Initialize Properties =================================== --> 
<!-- set global properties for build --> 
<property name="basedir" value="." /> 

<!-- created lib folder to store specifc jar files--> 
<property name="lib" value="${basedir}/lib" /> 

<!-- contains all java files ending with .java--> 
<property name="src" value="${basedir}/src" /> 

<!-- contains all classes ending with .class --> 
<property name="bin" value="${basedir}/bin" /> 

<!-- creates the directory for the reports --> 
<property name="report-dir" value="${basedir}/Test-Report" /> 
<!-- will create a folder within the report directory --> 
<property name="testng-report-dir" value="${report-dir}/TestNGreport" /> 


<!-- ====== Set the classpath ==== --> 
<path id="classpath"> 
    <pathelement location="${bin}" /> 
    <fileset dir="${lib}"> 
     <include name="*.jar" /> 
    </fileset> 
</path> 

<!-- Delete directories --> 
<target name="delete-dir"> 
    <!--delete the two directories listed below --> 
    <delete dir="${bin}" /> 
    <delete dir="${report-dir}" /> 
</target> 

<!-- Creating directories --> 
<target name="create" depends="delete-dir"> 
    <!--create the two directories listed below --> 
    <mkdir dir="${bin}" /> 
    <mkdir dir="${report-dir}" /> 
</target> 

<!-- Compile the java code from ${src} into ${bin} 
Will create the relevant class files and send them all into the bin directory in format: .class --> 
<target name="compile" depends="create"> 
    <javac srcdir="${src}" classpathref="classpath" includeAntRuntime="No" destdir="${bin}" /> 
    <echo> /* Compiled Directory Classes */ </echo> 
</target> 

<!-- Runs the file and generates Reportng report for TestNG--> 
<taskdef name="testng" classname="org.testng.TestNGAntTask" classpathref="classpath" /> 

<target name="testng-execution" depends="compile"> 
    <mkdir dir="${testng-report-dir}" /> 
    <testng outputdir="${testng-report-dir}" classpathref="classpath" useDefaultListeners="true"> 
     <xmlfileset dir="${basedir}" includes="testng.xml" /> 
    </testng> 
</target> 

ブラウザの工場:

が原因次に失敗するようです
@BeforeClass (alwaysRun = true) 
public void setup() throws Exception { 
    basePage = PageFactory.initElements(BrowserFactory.getDriver(), BasePage.class); 
    pageHeader = PageFactory.initElements(BrowserFactory.getDriver(), PageHeader.class); 
    phHomepage = PageFactory.initElements(BrowserFactory.getDriver(), Homepage.class); 
    signInPage = PageFactory.initElements(BrowserFactory.getDriver(), SignInPage.class); 
    hutLocalisePage = PageFactory.initElements(BrowserFactory.getDriver(), HutLocalisePage.class); 
    pizzaPage = PageFactory.initElements(BrowserFactory.getDriver(), PizzaPage.class); 
    excelSheet = PageFactory.initElements(BrowserFactory.getDriver(), ExcelReader.class); 
    yourOrderPage = PageFactory.initElements(BrowserFactory.getDriver(), YourOrderPage.class); 
    checkoutDetailsPage = PageFactory.initElements(BrowserFactory.getDriver(), CheckoutDetailsPage.class); 
    paymentInformationPage = PageFactory.initElements(BrowserFactory.getDriver(), PaymentInformationPage.class); 
    thanksPage = PageFactory.initElements(BrowserFactory.getDriver(), ThanksPage.class); 
    screenshot = PageFactory.initElements(BrowserFactory.getDriver(), Screenshot.class); 
    basePage.packageName = this.getClass().getPackage().toString(); 
} 


// Make sure driver instance is unassigned once tasks are completed 
@AfterClass (alwaysRun = true) 
public void quitDriver() throws Exception { 
    if (null != webdriver) { 
     getDriver().manage().deleteAllCookies(); 
     webdriver.quit(); 
     webdriver = null; 
    } 
} 

@AfterMethod (alwaysRun = true) 
public void takeScreenShotOnFailure(ITestResult testResult) throws WebDriverException, Exception { 
    if (testResult.getStatus() == ITestResult.FAILURE) { 
     System.out.println(testResult.getStatus()); 

     Date now = new Date(); 
     SimpleDateFormat dateFormat = new SimpleDateFormat("dd MMM yyyy"); 
     String time = dateFormat.format(now); 
     new File("C:\\Users\\gpb7642\\Desktop\\PhAutomationFramework\\FailedTests\\" + time).mkdir(); 

     String timeStamp = new SimpleDateFormat("HH.mm.SS").format(Calendar.getInstance().getTime()); 

     File scrFile = ((TakesScreenshot) BrowserFactory.getDriver()).getScreenshotAs(OutputType.FILE); 
     FileUtils.copyFile(scrFile, new File(("C:\\Users\\gpb7642\\Desktop\\PhAutomationFramework\\FailedTests\\" + time + "\\") + timeStamp.toString() + ", " + basePage.packageName + ", " + this.getClass().getSimpleName().toString() + "," + testResult.getName() + ".jpeg")); 
     //FileUtils.copyFile(scrFile, new File(("C:\\Users\\gpb7642\\Desktop\\PhAutomationFramework\\FailedTests\\" + time + "\\") + time + ", " + basePage.packageName + ", " + this.getClass().getSimpleName().toString() + "_" + testResult.getName() + ".jpeg")); 
    } 
} 


@AfterMethod (alwaysRun = true) 
public void takeScreenShotOnSuccessfulOrderConfirmation(ITestResult testResult) throws WebDriverException, Exception { 
    WebDriverWait wait; 
    wait = new WebDriverWait(getDriver(), 10); 

    if (testResult.getMethod().getMethodName().toString().contains("validateOrderWasSuccessful")) { 
     if(testResult.getStatus() == ITestResult.SUCCESS) { 
      Date now = new Date(); 
      SimpleDateFormat dateFormat = new SimpleDateFormat("dd MMM yyyy"); 
      String time = dateFormat.format(now); 
      new File("C:\\Users\\gpb7642\\Desktop\\PhAutomationFramework\\PassedTests\\" + time).mkdir(); 

      String timeStamp = new SimpleDateFormat("HH.mm.SS").format(Calendar.getInstance().getTime()); 

      //https://www.uat.pizzahut.co.uk/thanks?orderReference=aPiZ3Fee1Y0%3D 
      wait.until(ExpectedConditions.urlContains("https://www.uat.pizzahut.co.uk/thanks?")); 

      File scrFile = ((TakesScreenshot) BrowserFactory.getDriver()).getScreenshotAs(OutputType.FILE); 
      FileUtils.copyFile(scrFile, new File(("C:\\Users\\gpb7642\\Desktop\\PhAutomationFramework\\PassedTests\\" + time + "\\") + timeStamp.toString() + ", " + basePage.packageName + ", " + this.getClass().getSimpleName().toString() + "," + testResult.getName() + ".jpeg")); 
      //FileUtils.copyFile(scrFile, new File(("C:\\Users\\gpb7642\\Desktop\\PhAutomationFramework\\FailedTests\\" + time + "\\") + time + ", " + basePage.packageName + ", " + this.getClass().getSimpleName().toString() + "_" + testResult.getName() + ".jpeg")); 
     } 
    } 
} 

    @AfterMethod (alwaysRun = true) 
    //On Test Pass: LOG: Class Name & Method Name 
    public void onTestSuccess(ITestResult tr){ 
     if(tr.getStatus() == ITestResult.SUCCESS) { 
     DOMConfigurator.configure("log4j.xml"); 
     Log.info("@PASS: Package & Class: " + tr.getTestClass().getName().toString() + ", " + "Method: " + tr.getName().toString()); 
     } 
    } 

    @AfterMethod (alwaysRun = true) 
    //On Test Fail: LOG: Class Name & Method Name 
    public void onTestFailure(ITestResult tr) { 
     if(tr.getStatus() == ITestResult.FAILURE) { 
     DOMConfigurator.configure("log4j.xml"); 
     Log.info("@FAIL: Package & Class: " + tr.getTestClass().getName().toString() + ", " + "Method: " + tr.getName().toString()); 
    } 
    } 

    @AfterMethod (alwaysRun = true) 
    //On Test Skipped: LOG: Class Name & Method Name 
    public void onTestSkipped(ITestResult tr) { 
     if(tr.getStatus() == ITestResult.SKIP) { 
     DOMConfigurator.configure("log4j.xml"); 
     Log.info("@SKIPPED: Package & Class: " + tr.getTestClass().getName().toString() + ", "+ "Method: " + tr.getName().toString()); 
     } 
    } 

TestNGのファイル:

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" > 
<suite name="PH_Automation_Scripts_by" verbose="2"> 
    <test name="PH Automation Tests: Pizza Combinations"> 
     <classes> 
      <class name="PhFramework.pizzas.chickenSupreme.glutenFree.MediumTest"></class> 
     </classes> 
    </test> 
</suite> 

答えて

関連する問題