使用Maven运行单个测试

时间:2012-07-09 12:52:33

标签: testing maven selenium

我想使用maven运行一个测试 这是我的pom.xml:

           JUnit的       JUnit的       4.8.1       测试                   org.seleniumhq.selenium.client司机         硒-Java的客户端驱动器         1.0.2     

        <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>3.0-alpha-1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.2.1-b03</version>
        <scope>provided</scope>
    </dependency>

       WebTestAutomatisation              org.apache.maven.plugins        Maven的战争插件        2.0.2      

     <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>tomcat-maven-plugin</artifactId>
    <version>1.0-beta-1</version>
  </plugin>



     <!--  Start the tomcat server and  Deploy the war -->
    <plugin>
      <groupId>org.codehaus.cargo</groupId>
      <artifactId>cargo-maven2-plugin</artifactId>
      <version>1.2.2</version>
        <configuration>

    <fork>true</fork>
        <wait>false</wait>
            <container>
 <containerId>tomcat7x</containerId>
 <type>installed</type>
  <home>${env.CATALINA_HOME}</home>
   </container>
  <!-- <executions>
  <execution>
 <id>start-container</id>
  <phase>pre-integration-test</phase>
  <goals>
  <goal>start</goal>
   <goal>deploy</goal>
  </goals>
 </execution>
 <execution>
  <id>stop-container</id>
 <phase>post-integration-test</phase>
  <goals>
   <goal>stop</goal>
  </goals>
 </execution>
 </executions> -->
</configuration>

 <!-- Start the selenium server -->
 <plugin>
  <groupId>org.codehaus.mojo</groupId>
 <artifactId>selenium-maven-plugin</artifactId>
 <version>2.3</version>

  <executions>
     <execution>
      <id>start</id>
    <phase>pre-integration-test</phase>
  <goals>
   <goal>start-server</goal>
   </goals>
  <configuration>
   <background>true</background>
   <logOutput>true</logOutput>
  </configuration>
 </execution>
 <execution>

停止       整合后的测试           停止服务器                    
                 org.apache.maven.plugins      Maven的万无一失,插件       2.4.3                  org.junit:com.springsource.org.junit                        ** /功能/ * Test.java                    

 <!--   Running the tests in the functional tests package
      during the integration tests phase. -->
 <id>integration-tests</id>
 <phase>integration-test</phase>
  <goals>
<goal>test</goal>

        假           没有                ** /功能/ * Test.java                                   

</project>

我使用了这个命令:mvn -Dtest=MyTestClass test 我得到这个错误:

我尝试了这个命令,但它运行所有测试,而不是指定的mvn -Dit.test=MyTestClass verify

1 个答案:

答案 0 :(得分:0)

Jute maven plugin允许执行单个JUnit测试作为外部JVM进程