Configuring maven-failsafe-plugin to find integration tests not in src/test/java

后端 未结 2 2273
悲哀的现实
悲哀的现实 2021-02-19 18:44

My directory structure is like so:

  • src/integrationTest/java
  • src/test/java
  • src/main/java

I a

2条回答
  •  走了就别回头了
    2021-02-19 19:32

    By default failsafe is configured to only include IT*.java, *IT.java or *ITCase.java. While at the same time, only test sources from src/test/java are compiled. You need to modify both of these behaviors.

    1. Use build-helper-maven-plugin to add src/integationTest/java as test source for maven-compiler-plugin to pick up automatically. (You've already done this in your last attempt.)

    2. Direct maven-surefire-plugin to exclude your integration tests (see example below) or to include only non-integration tests (see default includes).

    3. Direct maven-failsafe-plugin to only include your integration tests instead of default includes.


    
      maven-surefire-plugin
      2.17
      
        
          **/*Stuff.java
        
      
    
    
      maven-failsafe-plugin
      2.17
      
        
          
            integration-test
            verify
          
        
      
      
        
          **/*Stuff.java
        
      
    
    

    In fact using testClassesDirectory might also work for limiting scope of each test plugin, but you would have to make changes to maven-compiler-plugin to output classes to different folders, perhaps splitting it's test-compile execution into two, so maybe it's not worth the effort.

提交回复
热议问题