2015-11-03 2 views
0

Я использую Selenium WebDriver, eclipse, testng и верный плагин. Я не могу запустить файл testng.xml из pom.xml. Пока я запускаю pom.xml, используя mvn test, он напрямую запускает файл, который находится в файле src/test/java/testCases. Просьба сообщить о моей ошибке. Спасибо Вам заранееНевозможно запустить testng.xml SELENIUM

Мой файл POM:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>com.test.maven</groupId> 
    <artifactId>NumberGenerator</artifactId> 
    <packaging>jar</packaging> 
    <version>1.0-SNAPSHOT</version> 
    <name>NumberGenerator</name> 
    <!-- <url>http://maven.apache.org</url> --> 
    <!-- <dependencies> --> 
    <!-- <dependency> --> 
    <!-- <groupId>junit</groupId> --> 
    <!-- <artifactId>junit</artifactId> --> 
    <!-- <version>4.11</version> --> 
    <!-- <scope>test</scope> --> 
    <!-- </dependency> --> 
    <!-- </dependencies> --> 

    <!-- <build> --> 
    <!-- <plugins> --> 
    <!-- <plugin> --> 
    <!-- <groupId>org.apache.maven.plugins</groupId> --> 
    <!-- <artifactId>maven-compiler-plugin</artifactId> --> 
    <!-- <version>2.3.2</version> --> 
    <!-- <configuration> --> 
    <!-- <source>1.6</source> --> 
    <!-- <target>1.6</target> --> 
    <!-- </configuration> --> 
    <!-- </plugin> --> 
    <!-- </plugins> --> 
    <!-- </build> --> 
    <!-- Source directory configuration --> 
    <build> 
     <plugins> 
      <!-- Following plugin executes the testng tests --> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-surefire-plugin</artifactId> 
       <version>2.19</version> 
       <configuration> 
        <!-- Suite testng xml file to consider for test execution --> 
        <suiteXmlFiles> 
         <suiteXmlFile>testng.xml</suiteXmlFile> 
         <!-- <suiteXmlFile>suites-test-testng.xml</suiteXmlFile> --> 
        </suiteXmlFiles> 
       </configuration> 
      </plugin> 
      <!-- Compiler plugin configures the java version to be usedfor compiling 
       the code --> 
      <plugin> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <configuration> 
        <source>1.6</source> 
        <target>1.6</target> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 
    <dependencies> 
     <!-- Dependency libraries to include for compilation --> 
     <dependency> 
      <groupId>org.testng</groupId> 
      <artifactId>testng</artifactId> 
      <version>6.9.8</version> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>4.10</version> 
      <scope>test</scope> 
     </dependency> 
    </dependencies> 
</project> 

Мой testng.xml:

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" > 
<suite name="Automation_Sobet_WBG_YiWanCai_TestSuite"> 
    <test name="Testing"> 
    <classes> 
     <class name="src/test/java/testCases.Automation_Sobet_WBG_YiWanCai"/> 
    </classes> 
    </test> 
</suite> 

Мои testCases:

package testCases; 

import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.firefox.FirefoxDriver; 
import org.testng.annotations.Test; 

import pageObjects.Home_Page; 
import pageObjects.ProductListing_Page; 
import utility.Constant; 
import utility.Log; 
import appModules.ProductSelectionConfirmation_Action; 
import appModules.SignIn_ActionBuilder; 

public class Automation_Sobet_WBG_YiWanCai { 
    public WebDriver driver; 


    // ******************** ABC **********************// 
    @Test(description = "ABC (复式)" , enabled = true) 
     public void WBG_FuShi() throws Exception { 
      try{ 
       driver = new FirefoxDriver(); 
       SignIn_ActionBuilder.Execute(driver); 
       ProductListing_Page.select_Title(driver, 1).click(); 
       ProductListing_Page.select_Title2(driver, 3).click(); 
       ProductSelectionConfirmation_Action.Pick_LotteryNum_All_Execute(driver, 6); 
       SignIn_ActionBuilder.Logout_Session(driver); 
       System.out.println("@ABC PASSES"); 
      }catch (Exception e){ 

       Log.error(e.getMessage()); 
       throw (e); 
      } 

     } 
+0

Я думаю, что это нормально. В любом случае вы указали точно и только один класс, который должен быть выполнен в testng.xml. Следовательно, он рассматривает «Automation_Sobet_WBG_YiWanCai». Попробуйте указать неверный путь для класса в testng.xml и посмотрите, не дает ли он ошибку. – MKay

+0

Или может быть, я не получил слово ** прямо ** в вашем вопросе. – MKay

+0

@ mk08 Я пытаюсь поместить неправильный путь для класса в testng.xml, но его до тех пор, пока он не будет работать. Когда я запустил его, кажется, что ничего не загружается/работает –

ответ

0

В файле testNG.xml вы должны укажите полное имя, а не путь к вашему классу. Это ниже указанное изменение должно сделать трюк.

<classes> 
    <class name="testCases.Automation_Sobet_WBG_YiWanCai"/> 
</classes> 

Кроме того, я предлагаю вам поместить файл testng.xml под траекторией src/test/resources/testng.xml и обновлять его в файле POM, как показано ниже.

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-surefire-plugin</artifactId> 
    <version>2.19</version> 
    <configuration> 
    <!-- Suite testng xml file to consider for test execution --> 
     <suiteXmlFiles> 
      <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile> 
     </suiteXmlFiles> 
    </configuration> 
</plugin> 

Если вы не используете JUnit, вы можете удалить его из файла POM.

+0

hi, testng.xml Я не могу запустить его –

+0

, какую ошибку вы получаете? – Sighil

Смежные вопросы