[ 
https://issues.apache.org/jira/browse/MNG-6966?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17170728#comment-17170728
 ] 

Karl Heinz Marbaise commented on MNG-6966:
------------------------------------------

Please make a full working example which shows the problem...

> Maven scope test not active in pre/post-integration
> ---------------------------------------------------
>
>                 Key: MNG-6966
>                 URL: https://issues.apache.org/jira/browse/MNG-6966
>             Project: Maven
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.6.0
>         Environment: Windows, Cygwin, Maven 3.6.0, Java 1.8.0, Spring-Boot 
> 2.2.6.RELEASE.
>            Reporter: Y. Gablin
>            Priority: Minor
>
> First, the relevant part of my {{pom.xml}} file:
> {code:xml}
>   <dependencies>
>     <dependency>
>       <groupId>org.postgresql</groupId>
>       <artifactId>postgresql</artifactId>
>     </dependency>
>     <dependency>
>       <groupId>org.springframework.boot</groupId>
>       <artifactId>spring-boot-starter-test</artifactId>
>       <scope>test</scope>
>     </dependency>
>     <dependency>
>       <groupId>com.h2database</groupId>
>       <artifactId>h2</artifactId>
>       <scope>test</scope>
>     </dependency>
>   </dependencies>
>   <build>
>     <plugins>
>       <plugin> <!-- Unit Tests -->
>         <groupId>org.apache.maven.plugins</groupId>
>         <artifactId>maven-surefire-plugin</artifactId>
>       </plugin>
>       <plugin> <!-- Validation Tests -->
>         <groupId>org.apache.maven.plugins</groupId>
>         <artifactId>maven-failsafe-plugin</artifactId>
>         <executions>
>           <execution>
>             <goals>
>               <goal>integration-test</goal>
>               <goal>verify</goal>
>             </goals>
>           </execution>
>         </executions>
>       </plugin>
>     </plugins>
>   </build>
> {code}
> I have Spring-Boot-2 validation tests, testing the full application stack 
> (annotated with {{SpringBootTest}}), from the (mock-)MVC layer to the JPA 
> layer (backed by an H2 in-memory database).
> All is fine, because I have the Maven H2 dependency as 
> {{<scope>test</scope>}}, and the validation tests, ran by the failsafe plugin 
> in the {{integration-test}} phase, do benefit from having H2 in the 
> classpath, which implies that Spring-Boot generates the required 
> {{DataSource}}, and so on.
> Now, I have new tests to run in the {{integration-test}} phase, that need to 
> have the embedded Tomcat actually running, which is precisely what this 
> additional fragment is made for:
> {code:xml}
>       <plugin>
>         <groupId>org.springframework.boot</groupId>
>         <artifactId>spring-boot-maven-plugin</artifactId>
>         <executions>
>           <execution>
>             <id>pre-integration-test</id>
>             <goals>
>               <goal>start</goal>
>             </goals>
>           </execution>
>           <execution>
>             <id>post-integration-test</id>
>             <goals>
>               <goal>stop</goal>
>             </goals>
>           </execution>
>         </executions>
>       </plugin>
> {code}
> The [documentation for this 
> plugin|https://docs.spring.io/autorepo/docs/spring-boot/2.1.4.RELEASE/maven-plugin/plugin-info.html]
>  tells us, that those goals are respectively attached to phases 
> {{pre-integration-test}} and {{post-integration-test}}.
> My problem is that, when the application starts, Spring Boot does *not* find 
> H2 in the classpath, and thus does not create a {{DataSource}}, which my 
> application, _and tests from the {{integration-test}} phase_, require!
> I conclude from that, that the Maven {{test}} scope does _not_ apply to the 
> {{pre-integration-test}} and {{post-integration-test}} phases, which does not 
> seem logical / consistent to me.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to