-
-
Notifications
You must be signed in to change notification settings - Fork 0
Leverage test instead of using main app #51
Comments
How I see the implementation: there is a special annotation (something like Then we just add to a test class (annotated with @WebMvcTest) an empty test method (annotated with @HttpClientTest) and it runs all test from *.http files that we set as parameter of our annotation. |
Seems a very good implementation idea! WorkaroundFor now, we managed to configure our build in a way that we can leverage the testing classpath by using ( leaving this just as a reference to others, since you're implementation if a far better idea ): In the pom.xml: <plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>start-integration-spring</id>
<phase>pre-integration-test</phase>
<configuration>
<skip>${skipITs}</skip>
<useTestClasspath>true</useTestClasspath>
<mainClass>*****.IntegrationTestsEntryPoint</mainClass>
<directories>
<directory>${project.build.testOutputDirectory}</directory>
</directories>
</configuration>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop-integration-spring</id>
<phase>post-integration-test</phase>
<configuration>
</configuration>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin> Then in your main class ( in this case kotlin but java would use the same ): @SpringBootApplication
@Import(
WithPostgres::class,
WithMockServer::class,
WithPostgres::class,
WithRedis::class
)
open class IntegrationTestsEntryPoint {
companion object {
@JvmStatic
fun main(args: Array<String>) {
SpringApplication.run(Application::class.java, *args)
}
}
} The With** imports are just TestConfiguration classes with expose the TestContainer beans. |
Just note about my next steps. I have investigated how to implement jUnit extension: unfortunately we cannot replace a test itself, we can run our code before or after test. I have decided to go another way like other solutions already use, see Spring Boot Testing: MockMvc vs. WebTestClient vs. TestRestTemplate: to implement a builder-style component to customize command line and execute it. |
* Rename cli-builder to command-line; add a Spring Boot integration test as #51 proposed (see GitHub). * Fix GitLab CI configuration * Fix style issues and import * Add the spring-boot-test module with autoconfiguration * Fix GitLab CI configuration * Add unit-tests, remove unused imports * Clean GitLab CI configuration * Spring Boot Test Autoconfiguration * Descrease complexity * Increase code coverage * Increase code coverage * Increase code coverage * Fix style issue * Increase code coverage * Increase code coverage * Fix style issues
Now implementation is in the |
…est autoconfiguration. (#60) * Bump org.jetbrains:annotations from 24.0.1 to 24.1.0 (#58) Bumps [org.jetbrains:annotations](https://github.com/JetBrains/java-annotations) from 24.0.1 to 24.1.0. - [Release notes](https://github.com/JetBrains/java-annotations/releases) - [Changelog](https://github.com/JetBrains/java-annotations/blob/master/CHANGELOG.md) - [Commits](JetBrains/java-annotations@24.0.1...24.1.0) --- updated-dependencies: - dependency-name: org.jetbrains:annotations dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump org.apache.maven.plugins:maven-project-info-reports-plugin (#59) Bumps [org.apache.maven.plugins:maven-project-info-reports-plugin](https://github.com/apache/maven-project-info-reports-plugin) from 3.4.5 to 3.5.0. - [Commits](apache/maven-project-info-reports-plugin@maven-project-info-reports-plugin-3.4.5...maven-project-info-reports-plugin-3.5.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-project-info-reports-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add the proxy feature * The report path is customazible * CLI builder * Update ChangeLog * Bump actions/setup-java from 3 to 4 (#62) Bumps [actions/setup-java](https://github.com/actions/setup-java) from 3 to 4. - [Release notes](https://github.com/actions/setup-java/releases) - [Commits](actions/setup-java@v3...v4) --- updated-dependencies: - dependency-name: actions/setup-java dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Update Maven plugin's groupId * Bump mockito.version from 5.7.0 to 5.8.0 (#65) Bumps `mockito.version` from 5.7.0 to 5.8.0. Updates `org.mockito:mockito-core` from 5.7.0 to 5.8.0 - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](mockito/mockito@v5.7.0...v5.8.0) Updates `org.mockito:mockito-junit-jupiter` from 5.7.0 to 5.8.0 - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](mockito/mockito@v5.7.0...v5.8.0) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-minor - dependency-name: org.mockito:mockito-junit-jupiter dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Fix GitLab CI configuration * Fix GitLab CI configuration * Fix GitLab CI configuration * Fix stderr integration test * Fix style issue * Fix GitLab CI configuration * Spring Boot Test extension with autoconfiguration * Rename cli-builder to command-line; add a Spring Boot integration test as #51 proposed (see GitHub). * Fix GitLab CI configuration * Fix style issues and import * Add the spring-boot-test module with autoconfiguration * Fix GitLab CI configuration * Add unit-tests, remove unused imports * Clean GitLab CI configuration * Spring Boot Test Autoconfiguration * Descrease complexity * Increase code coverage * Increase code coverage * Increase code coverage * Fix style issue * Increase code coverage * Increase code coverage * Fix style issues * Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.6.2 to 3.6.3 (#68) Bumps [org.apache.maven.plugins:maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.6.2 to 3.6.3. - [Release notes](https://github.com/apache/maven-javadoc-plugin/releases) - [Commits](apache/maven-javadoc-plugin@maven-javadoc-plugin-3.6.2...maven-javadoc-plugin-3.6.3) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-javadoc-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Update documentation * spring-boot-test: parameters documentation * Add javadoc and readme to the command-line module * Update reamde and javadoc * Add readme and javadoc to Spring Boot Test autoconfiguration * Update site * Bump org.apache.maven.plugins:maven-failsafe-plugin from 3.2.2 to 3.2.3 (#71) Bumps [org.apache.maven.plugins:maven-failsafe-plugin](https://github.com/apache/maven-surefire) from 3.2.2 to 3.2.3. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](apache/maven-surefire@surefire-3.2.2...surefire-3.2.3) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-failsafe-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump org.apache.maven.plugins:maven-surefire-plugin from 3.2.2 to 3.2.3 (#70) Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.2.2 to 3.2.3. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](apache/maven-surefire@surefire-3.2.2...surefire-3.2.3) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump github/codeql-action from 2 to 3 (#72) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2 to 3. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](github/codeql-action@v2...v3) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Next version * Update TOC in readme * Fix TOC * Update javadoc and release profile * Bump org.apache.maven.plugins:maven-compiler-plugin (#74) Bumps [org.apache.maven.plugins:maven-compiler-plugin](https://github.com/apache/maven-compiler-plugin) from 3.11.0 to 3.12.0. - [Release notes](https://github.com/apache/maven-compiler-plugin/releases) - [Commits](apache/maven-compiler-plugin@maven-compiler-plugin-3.11.0...maven-compiler-plugin-3.12.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-compiler-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Implemented in v1.1.1 |
Hi,
Is your feature request related to a problem? Please describe.
We would like to avoid mixing up test related code/profiles with our src. This would also help us in leveraging the already existing setup for @SpringBootTests ( spin up kafka, mockserver, postgres, etc ), instead of duplicating everything for the ijhttp integration tests.
Describe the solution you'd like
Would like a way of connecting the integration-test of ijhttp with a springboottest class.
PS: Btw, I've added a comment on a LinkedIn page, sorry for the "spam" :)
The text was updated successfully, but these errors were encountered: