0

0 тестов запускается, когда я выполняю testng.xml с использованием файла POM с использованием Maven-surefire.Тесты TestNG не запускаются при выполнении testng.xml с использованием файла POM с использованием maven-surefire

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

Но, когда я включаю testng.xml файл (как показано ниже), то его не работает:

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-surefire-plugin</artifactId> 
    <version>2.14.1</version> 
    <configuration> 
     <suiteXmlFiles> 
      <suiteXmlFile>testng.xml</suiteXmlFile> 
     </suiteXmlFiles> 
    </configuration> 
</plugin> 

Ниже мой 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/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>SAPAutomation</groupId> 
    <artifactId>SAPAutomation</artifactId> 
    <!-- <version>3.2</version> --> 
    <version>0.0.1-SNAPSHOT</version> 
    <packaging>jar</packaging> 

    <name>SAPAutomation</name> 
    <url>http://maven.apache.org</url> 

    <!-- For javadocs --> 
    <build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-eclipse-plugin</artifactId> 
      <version>2.17</version> 
      <configuration> 
       <downloadSources>true</downloadSources> 
       <downloadJavadocs>true</downloadJavadocs> 
      </configuration> 
     </plugin> 

     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-surefire-plugin</artifactId> 
      <version>2.14.1</version> 
      <configuration> 
       <suiteXmlFiles> 
        <suiteXmlFile>testng.xml</suiteXmlFile> 
       </suiteXmlFiles> 
      </configuration> 
     </plugin> 

    <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-compiler-plugin</artifactId> 
     <version>3.3</version> 
     <configuration> 
      <source>1.8</source> 
      <target>1.8</target> 
     </configuration> 
    </plugin> 

    <!-- To exclude unwanted Package ex: com.SAPAutomation.TEMP etc--> 
    <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-jar-plugin</artifactId> 
     <version>2.6</version> 
     <configuration> 
      <excludes> 
      <exclude>**/com/SAPAutomation/Temp/*</exclude> 
      </excludes> 
     </configuration> 
     </plugin> 
    </plugins> 
    </build> 

    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    </properties> 

    <dependencies> 
     <dependency> 
      <groupId>info.cukes</groupId> 
      <artifactId>cucumber-picocontainer</artifactId> 
      <version>1.1.5</version> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>info.cukes</groupId> 
      <artifactId>cucumber-junit</artifactId> 
      <version>1.1.5</version> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
       <groupId>org.seleniumhq.selenium</groupId> 
       <artifactId>selenium-server</artifactId> 
       <version>2.45.0</version> 
     </dependency> 
     <dependency> 
      <groupId>org.seleniumhq.selenium</groupId> 
      <artifactId>selenium-firefox-driver</artifactId> 
      <version>2.45.0</version> 
     </dependency> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>4.11</version> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.poi</groupId> 
      <artifactId>poi</artifactId> 
      <version>3.11</version> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.poi</groupId> 
      <artifactId>poi-ooxml</artifactId> 
      <version>3.11</version> 
     </dependency> 
     <dependency> 
      <groupId>org.codehaus.jackson</groupId> 
      <artifactId>jackson-mapper-asl</artifactId> 
      <version>1.9.2</version> 
     </dependency> 
     <dependency> 
      <groupId>org.codehaus.jackson</groupId> 
      <artifactId>jackson-core-asl</artifactId> 
      <version>1.9.2</version> 
     </dependency> 
     <dependency> 
      <groupId>com.googlecode.json-simple</groupId> 
      <artifactId>json-simple</artifactId> 
      <version>1.1</version> 
     </dependency> 
     <dependency> 
      <groupId>org.testng</groupId> 
      <artifactId>testng</artifactId> 
      <version>6.8.15</version> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>net.sourceforge.jtds</groupId> 
      <artifactId>jtds</artifactId> 
      <version>1.3.1</version> 
     </dependency> 
     <dependency> 
      <groupId>log4j</groupId> 
      <artifactId>log4j</artifactId> 
      <version>1.2.16</version> 
     </dependency> 
     <dependency> 
      <groupId>com.github.detro.ghostdriver</groupId> 
      <artifactId>phantomjsdriver</artifactId> 
      <version>1.0.1</version> 
     </dependency> 
     <dependency> 
      <groupId>org.codeartisans.thirdparties.swing</groupId> 
      <artifactId>org-openide-util</artifactId> 
      <version>8.6.2</version> 
     </dependency> 


    <dependency> 
      <groupId>com.oracle</groupId> 
      <artifactId>ojdbc14-10.2.0.4.0</artifactId> 
      <version>10.2.0.4.0</version> 
      <scope>system</scope> 
      <systemPath>${basedir}/src/lib/ojdbc14.jar</systemPath> 
     <!--  <systemPath>${java.home}/lib/ojdbc14.jar</systemPath> --> 
     </dependency> 

    <dependency> 
     <groupId>org.monte.screenrecorder</groupId> 
     <artifactId>MonteScreenRecorder</artifactId> 
     <version>10</version> 
     <scope>system</scope> 
     <systemPath>${basedir}/src/lib/MonteScreenRecorder.jar</systemPath> 
     <!-- <systemPath>${java.home}/lib/ojdbc14.jar</systemPath> --> 
    </dependency> 

<!--  <repositories> 
      <repository> 
       <id>ojdbc14</id> 
       <url>http://www.oracle.com/technetwork/apps-tech/jdbc-10201-088211.html</url> 
      </repository> 
     </repositories> --> 

    </dependencies> 
</project> 

Мой testng.xml файл:

<suite name="Suite" parallel="tests"> 
     <listeners> 
      <listener class-name="com.SAPAutomation.Listners.RetryListener"/> 
     </listeners> 

    <test name="Test1"> 
     <parameter name="TestCaseId" value="TC1" /> 
     <classes> 
      <class name="com.xyz.abc.MyAutomationTestByXML"/> 
     </classes> 
     </test> 

    <test name="Test2"> 
     <parameter name="TestCaseId" value="TC2" /> 
     <classes> 
      <class name="com.xyz.abc.MyAutomationTestByXML"/> 
     </classes> 
    </test> 


    <test name="Test3"> 
     <parameter name="TestCaseId" value="TC3" /> 
     <classes> 
      <class name="com.xyz.abc.MyAutomationTestByXML"/> 
     </classes> 
    </test> 
</suite> 

Тест результат выполнения pom.xml:

[INFO] Scanning for projects... 
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for SAPAutomation:SAPAutomation:jar:0.0.1-SNAPSHOT 
[WARNING] 'dependencies.dependency.systemPath' for com.oracle:ojdbc14-10.2.0.4.0:jar should not point at files within the project directory, ${basedir}/src/lib/ojdbc14.jar will be unresolvable by dependent projects @ line 153, column 16 
[WARNING] 'dependencies.dependency.systemPath' for org.monte.screenrecorder:MonteScreenRecorder:jar should not point at files within the project directory, ${basedir}/src/lib/MonteScreenRecorder.jar will be unresolvable by dependent projects @ line 162, column 15 
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build. 
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects. 
[WARNING] 
[INFO] 
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1 
[INFO]                   
[INFO] ------------------------------------------------------------------------ 
[INFO] Building SAPAutomation 0.0.1-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ SAPAutomation --- 
[INFO] Using 'UTF-8' encoding to copy filtered resources. 
[INFO] skip non existing resourceDirectory C:\AutomationWorkSpace\SAPAutomation\src\main\resources 
[INFO] 
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ SAPAutomation --- 
[INFO] Nothing to compile - all classes are up to date 
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ SAPAutomation --- 
[INFO] Using 'UTF-8' encoding to copy filtered resources. 
[INFO] Copying 1 resource 
[INFO] 
[INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) @ SAPAutomation --- 
[INFO] Changes detected - recompiling the module! 
[INFO] Compiling 35 source files to C:\AutomationWorkSpace\SAPAutomation\target\test-classes 
[INFO] 
[INFO] --- maven-surefire-plugin:2.14.1:test (default-test) @ SAPAutomation --- 
[INFO] Surefire report directory: C:\AutomationWorkSpace\SAPAutomation\target\surefire-reports 

------------------------------------------------------- 
T E S T S 
------------------------------------------------------- 
Running TestSuite 
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.496 sec 

Results : 

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0 

[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD SUCCESS 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 6.137 s 
[INFO] Finished at: 2015-04-09T15:01:01+00:00 
[INFO] Final Memory: 24M/277M 
[INFO] ------------------------------------------------------------------------ 

Просьба сообщить.

Проблема по-прежнему сохраняется даже после полного ввода Testng.xml в файл POM.xml.

<plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-surefire-plugin</artifactId> 
      <version>2.14.1</version> 
      <configuration> 
       <suiteXmlFiles> 
        <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile> 
       </suiteXmlFiles> 
      </configuration> 
     </plugin> 

[INFO] Scanning for projects... 
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for SAPAutomation:SAPAutomation:jar:0.0.1-SNAPSHOT 
[WARNING] 'dependencies.dependency.systemPath' for com.oracle:ojdbc14-10.2.0.4.0:jar should not point at files within the project directory, ${basedir}/src/lib/ojdbc14.jar will be unresolvable by dependent projects @ line 154, column 16 
[WARNING] 'dependencies.dependency.systemPath' for org.monte.screenrecorder:MonteScreenRecorder:jar should not point at files within the project directory, ${basedir}/src/lib/MonteScreenRecorder.jar will be unresolvable by dependent projects @ line 163, column 15 
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build. 
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects. 
[WARNING] 
[INFO] 
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1 
[INFO]                   
[INFO] ------------------------------------------------------------------------ 
[INFO] Building SAPAutomation 0.0.1-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ SAPAutomation --- 
[INFO] Using 'UTF-8' encoding to copy filtered resources. 
[INFO] skip non existing resourceDirectory C:\AutomationWorkSpace\SAPAutomation\src\main\resources 
[INFO] 
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ SAPAutomation --- 
[INFO] Nothing to compile - all classes are up to date 
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ SAPAutomation --- 
[INFO] Using 'UTF-8' encoding to copy filtered resources. 
[INFO] Copying 3 resources 
[INFO] 
[INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) @ SAPAutomation --- 
[INFO] Changes detected - recompiling the module! 
[INFO] Compiling 35 source files to C:\AutomationWorkSpace\SAPAutomation\target\test-classes 
[INFO] 
[INFO] --- maven-surefire-plugin:2.14.1:test (default-test) @ SAPAutomation --- 
[INFO] Surefire report directory: C:\AutomationWorkSpace\SAPAutomation\target\surefire-reports 

------------------------------------------------------- 
T E S T S 
------------------------------------------------------- 
Running TestSuite 
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.501 sec 

Results : 

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0 

[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD SUCCESS 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 7.402 s 
[INFO] Finished at: 2015-04-14T17:31:11+00:00 
[INFO] Final Memory: 22M/167M 
[INFO] ------------------------------------------------------------------------ 
+0

Проверьте правильность написания всех файлов, например. testng.xml как это написано. Также проверьте, что файл testng.xml находится в правильном месте. –

ответ

0

В Maven-плагин-верный, обеспечивают полный путь из-под вашего проекта в файл testng.xml - Пример: <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>

+0

Все еще я получаю сообщение об успешном завершении 0, даже после предоставления полного пути/добавления нового TestNG.xml « --------------- ---------------------------------------- ИСПЫТАНИЯ ------- ------------------------------------------------ Запуск TestSuite тесты запуска: 0, Отказы: 0, ошибки: 0, пропущено: 0, Время, прошедшее: 0,455 сек Результаты: тесты выполняются: 0, Аварии: 0, Ошибки: 0, пропущено: 0 -» – user2451016

0

Вы должны указать полный путь к TestNG. xml-файл для Maven, чтобы забрать его.

+0

Still Я получаю сообщение 0 успешно прошло успешно. " ----------------------------------------------- -------- ИСПЫТАНИЯ --------------------------------------- ---------------- Запуск TestSuite Тесты: 0, Ошибки: 0, Ошибки: 0, Пропущенные: 0, Истекшее время: 0,455 сек. Результаты: Тесты: 0 , Ошибки: 0, Ошибки: 0, Пропущенные: 0 - " – user2451016

0

Вы можете разместить файл testng.xml в проекте непосредственно с вашим pom-файлом, после чего он выполнит ваш набор тестов.

0

Вышеупомянутая проблема решена с использованием обновленной версии плагина Maven-Surefire в упомянутом POM.xml. Целая установка жила Счастье после & после !! Thanks

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