排除使用mvn配置文件的硒测试

时间:2013-09-27 15:36:42

标签: xml unit-testing maven selenium integration-testing

我正在尝试使用下面的代码排除selenium测试(pom.xml - 通过添加配置文件)但它不起作用,我的问题是我做错了什么?:

我正在运行mvn clean install

<profiles>
    <profile>
        <id>local</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <configuration>
                        <includes>
                            <!-- Inclure les tests unitaires ici ... -->
                        </includes>
                        <excludes>
                            <exclude>**/selenium/**/*Test.java</exclude>  <!-- Exclure les tests Selenium ici ... -->
                        </excludes>
                    </configuration>
                    <executions>
                        <execution>
                            <id>surefire-integration-test</id>
                            <phase>integration-test</phase>
                            <goals>
                                <goal>test</goal> <!-- La phase integration-test va lancer les tests... -->
                            </goals>
                            <configuration>
                                <skip>false</skip>
                                <includes>
                                    <include>**/selenium/**/*Test.java</include> <!-- ... Inclure les tests Selenium ici -->
                                </includes>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>


            </plugins>
        </build>
    </profile>


</profiles>

1 个答案:

答案 0 :(得分:1)

首先,让我们具体一点。我们不排除Selenium测试 - 我们排除测试框架测试。

找出您正在使用的测试框架...... jUnitTestNG等。

按文件/包排除测试(需要maven surefire插件)

<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.16</version>
        <configuration>
          <includes>
            <include>Sample.java</include>
          </includes>
        </configuration>
      </plugin>
    </plugins>
  </build>
  [...]
</project>