Можем ли мы выполнить несколько профилей в одном файле pom. xml - PullRequest
0 голосов
/ 28 мая 2020

Я создал проект Maven в Eclipse и в нем есть 2 xml файлов. Я создал 2 профиля «TestNG. xml» и «TestNG2. xml» в файле pom. xml для моего проекта Maven. Я выполнил следующую команду из командной строки - mvn test

Ожидаемое поведение: должны быть выполнены TC под файлами TestNG. xml и TestNG2. xml. Фактическое поведение: выполняются только TC в файле TestNG2. xml.

ПРИМЕЧАНИЕ. - Когда я выполняю файлы. xml индивидуально с помощью приведенной ниже команды, он отлично работает {TestNG. xml file был профилирован как регрессия в файле pom. xml} - mvn test -PRegression

Ниже приведен снимок моего кода из pom. xml file

 <groupId>Rohit</groupId>
  <artifactId>MavenProject05202020</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>MavenProject05202020</name>
  <url>http://maven.apache.org</url>
  <profiles>
        <profile>
            <id>Regression</id>
 <!--  Below is MAVEN SURE FIRE PLUGIN. This will help to execute all your TCs present in your test folder{i.e.:-src/test/java}-->
  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>3.0.0-M4</version>
          <configuration>
          <suiteXmlFiles>
            <suiteXmlFile>testng.xml</suiteXmlFile>
          </suiteXmlFiles>
        </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
        </profile>

<!--  Below is MAVEN SURE FIRE PLUGIN. 
        <profile>
           <id>Smoke</id>
  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>3.0.0-M4</version>
          <configuration>
          <suiteXmlFiles>
            <suiteXmlFile>testng2.xml</suiteXmlFile>
          </suiteXmlFiles>
        </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
         </profile>
  </profiles>



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

  <dependencies>
<!--  below is the dependency for Selenium project -->
      <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.8.1</version>
      </dependency>
<!-- Below is the dependency for TESTNG. -->
      <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>7.1.0</version>
            <scope>test</scope>
      </dependency>
<!--  Below is the dependency for RestAPITest project -->
      <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>rest-assured</artifactId>
            <version>4.3.0</version>
            <scope>test</scope>
      </dependency>
  </dependencies>
</project>

1 Ответ

1 голос
/ 28 мая 2020

Если вы просто определите плагин surefire дважды, эти определения будут переопределять друг друга.

Вместо этого вам нужно определить <execution> в объявлении плагина и привязать его к фазе. Плагины могут иметь более одного исполнения в блоке <executions>.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...