[MNG-6966] Maven scope test not active in pre/post-integration
- Dominant language
- Java
- Stars
- 5.3k
- Forks
- 3.1k
- Avg merge
- 20h 42m
- Merged PRs (30d)
- 297
Description
**[Y. Gablin](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=ygablin)** opened **[MNG-6966](https://issues.apache.org/jira/browse/MNG-6966?redirect=false)** and commented
First, the relevant part of my `pom.xml` file:
```xml
org.postgresql
postgresql
org.springframework.boot
spring-boot-starter-test
test
com.h2database
h2
test
org.apache.maven.plugins
maven-surefire-plugin
org.apache.maven.plugins
maven-failsafe-plugin
integration-test
verify
```
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 `test`, 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:
```xml
org.springframework.boot
spring-boot-maven-plugin
pre-integration-test
start
post-integration-test
stop
```
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.
---
**Affects:** 3.6.0
Contributor guide
Research direction
Reproduce the report using the provided pom.xml, focusing on the maven-failsafe-plugin and spring-boot-maven-plugin executions around the pre-integration-test and post-integration-test phases. Trace how Maven builds the application classpath for those phases and compare it with integration-test execution. Done means the test-scoped dependency behavior is either corrected or documented with a verified explanation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring-boot
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100