2013-07-09 38 views
13

Làm thế nào mà Maven bỏ qua tất cả các bài kiểm tra của tôi theo mặc định? Tôi có một pom.xml với một vài tiểu sử và tôi không thể chạy các bài kiểm tra của mình thông qua cả hai. Một trong hồ sơ của tôi trông giống nhưMaven tự động bỏ qua các bài kiểm tra

<profile> 
     <id>jsf-test</id> 
     <dependencies> 
      <dependency> 
       <groupId>org.jboss.as</groupId> 
       <artifactId>jboss-as-arquillian-container-remote</artifactId> 
       <version>${jboss.version}</version> 
       <scope>test</scope> 
      </dependency> 
      <dependency> 
       <groupId>com.jsf.tests</groupId> 
       <artifactId>jsf-app</artifactId> 
       <version>${jsf-app.version}</version> 
       <type>war</type> 
      </dependency> 
     </dependencies> 
     <build> 
      <plugins>     
       <plugin> 
        <artifactId>maven-dependency-plugin</artifactId> 
        <version>2.6</version> 
        <executions> 
         <execution> 
          <id>copy-jsf-app</id> 
          <phase>validate</phase> 
          <goals> 
           <goal>copy</goal> 
          </goals> 
          <configuration> 
           <artifactItems> 
            <artifactItem> 
             <groupId>com.jsf.tests</groupId> 
             <artifactId>jsf-app</artifactId> 
             <version>${jsf-app.version}</version> 
             <type>war</type> 
             <destFileName>jsfapp.war</destFileName> 
             <outputDirectory>target</outputDirectory> 
            </artifactItem> 
           </artifactItems> 
          </configuration> 
         </execution> 
        </executions> 
       </plugin> 

       <plugin> 
        <artifactId>maven-surefire-plugin</artifactId> 
        <version>${maven-surefire.version}</version> 
        <configuration> 
         <skipTests>false</skipTests> <!-- desperate trial --> 
         <properties> 
          <property> 
           <name>listener</name> 
           <value>${testng.listeners}</value> 
          </property> 
         </properties> 
        </configuration> 
       </plugin> 
      </plugins> 
     </build> 
    </profile> 

Nếu tôi chạy mvn verify -Pjsf-test sau đó dự án được biên dịch, jsf-app vật được sao chép một cách chính xác vào mục tiêu và kiểm tra được bỏ qua. mvn verify -Dtest=TestCalculator có cùng kết quả. Tôi đang sử dụng ArquillianTestNG để thực hiện các thử nghiệm thực tế nhưng tôi không chắc liệu nó có quan trọng đối với câu hỏi này hay không.

EDIT

Chạy trong debug sẽ cung cấp (phần liên quan)

[DEBUG] (s) reportFormat = brief 
[DEBUG] (s) reportsDirectory = /home/pmensik/Work/workspace/epp-test/cdi-arquillian- test/target/surefire-reports 
[DEBUG] (f) reuseForks = true 
[DEBUG] (s) runOrder = filesystem 
[DEBUG] (s) skip = true 
[DEBUG] (s) skipTests = false 
[DEBUG] (s) systemPropertyVariables = {jsfPortlet=true} 
[DEBUG] (s) testClassesDirectory = /home/pmensik/Work/workspace/epp-test/cdi-arquillian-test/target/test-classes 
[DEBUG] (s) testFailureIgnore = false 
[DEBUG] (s) testNGArtifactName = org.testng:testng 
[DEBUG] (s) testSourceDirectory = /home/pmensik/Work/workspace/epp-test /cdi-arquillian-test/src/test/java 
[DEBUG] (s) trimStackTrace = true 
[DEBUG] (s) useFile = true 
[DEBUG] (s) useManifestOnlyJar = true 
[DEBUG] (s) useSystemClassLoader = true 
[DEBUG] (s) useUnlimitedThreads = false 
[DEBUG] (s) workingDirectory = /home/pmensik/Work/workspace/epp-test/cdi-arquillian-test 
[DEBUG] (s) project = MavenProject: org.jboss.gatein.test:cdi-portlet-test:6.1-ER01 @ /home/pmensik/Work/workspace/epp-test/cdi-arquillian-test/pom.xml 
[DEBUG] (s) session = [email protected] 
[DEBUG] -- end configuration -- 
[INFO] Tests are skipped. 

thử nghiệm đơn giản của tôi trông như thế này

public class Test { 

    @Drone 
    protected WebDriver driver; 

    @Deployment(testable = false) 
    public static WebArchive createTestArchive() { 
     return ShrinkWrap.createFromZipFile(WebArchive.class, new File("target/CDIPortlet.war")); 
    } 

    @Test 
    public void testCase{ 
     //... 
    } 

} 
+0

Bạn có chắc chắn bạn không chạy với '-DskipTests' bằng cách nào đó không? 'Mvn clean verify' hoặc' mvn clean install' làm gì? – vikingsteve

+0

Thử chạy với '-X' để gỡ lỗi đầu ra, sau đó xem cấu hình của plugin chắc chắn. Tôi cũng sẽ nghi ngờ một vấn đề thừa kế plugin. Plugin chắc chắn có được định cấu hình trong POM mẹ không? – user944849

+0

và các bài kiểm tra của bạn được xác định ở đâu? –

Trả lời

23

Sản lượng debug thấy điều này:

[DEBUG] (s) skip = true 

không chỉ bỏ qua chạy thử nghiệm, nó cũng sẽ bỏ qua biên soạn chúng. Kiểm tra POM cha (tham chiếu trực tiếp bởi POM này, cũng POM bất kỳ công ty hoặc siêu POMs giới thiệu bởi Arquillian) để xem nơi lá cờ này đang được thiết lập, nếu bạn tò mò.

Việc sửa chữa là thêm

<skip>false</skip> 

để cấu hình cắm chắc chắn hơn trong mô-đun này, hoặc thêm

-Dmaven.test.skip=false 

vào dòng lệnh của bạn.

Reference

+1

đúng - các thử nghiệm được biên dịch, nhưng không được chạy. –

+1

đúng - các bài kiểm tra thậm chí không được biên dịch. –

Các vấn đề liên quan