Maven mvn集成测试无法运行我的测试
我正在用Selenium、TestNG和Maven进行自动化测试。当我在cmd中执行:mvn集成测试时,maven不会运行我的测试。我是Maven的新手,我读了一些例子,但没有找到解决问题的方法 以下是我的pom.xml:Maven mvn集成测试无法运行我的测试,maven,selenium,testng,Maven,Selenium,Testng,我正在用Selenium、TestNG和Maven进行自动化测试。当我在cmd中执行:mvn集成测试时,maven不会运行我的测试。我是Maven的新手,我读了一些例子,但没有找到解决问题的方法 以下是我的pom.xml: <dependencies> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId&
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<classifier>jdk15</classifier>
<version>5.11</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>2.31.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>selenium-maven-plugin</artifactId>
<executions>
<execution>
<phase>pre-integration-test</phase>
<goals>
<goal>start-server</goal>
</goals>
<configuration>
<background>true</background>
</configuration>
</execution>
<execution>
<id>stop-selenium</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop-server</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<include>**/MainPage*.java </include>
</configuration>
<executions>
<execution>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
提前感谢!:) 第一件事是使用而不是,因为maven surefire插件用于单元测试,而maven failsafe插件用于运行集成测试。 此外,您需要将集成测试命名为
**/IT*.java
**/*IT.java
**/*ITCase.java
但是在您的情况下,您应该有一个单独的模块,其中包含要在开发中的web应用程序上运行的集成测试。谢谢!我已经将我的测试更改为单元测试(使用maven surefire插件),并将我的类的名称更改为:MainPageTest.java,它成功了。你没有单元测试,你有集成测试,所以你应该和我提出的建议一起使用。
**/IT*.java
**/*IT.java
**/*ITCase.java