Closed sandeep-tukaram closed 3 months ago
The integration test didn't run for me either until I renamed it so that it ended with the word "Test".
For example, I renamed the class HelloControllerIT
to HelloControllerIntegrationTest
. After doing that, the test ran successfully using Maven.
Before
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO]
After
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO]
Hi @sandeep-tukaram. Thanks for submitting this issue! I see similar behavior on a Mac so I don't think it is related to windows. I do think the problem is exclusive to Maven, but it is something to fix so all tests run with both Maven and Gradle.
When the file is named HelloControllerIT
and I run ./mvnw clean package
I get the following output:
[INFO] Results:
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
However if I rename the file to HelloControllerITest
and run the same command the additional test runs:
[INFO] Results:
[INFO]
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
This makes sense as the class name HelloControllerIT
doesn't match the wildcard pattern.
Would you like to submit a PR for this issue?
Hi @robertmcnees, @Buzzardo ,
I've submitted a PR (#176) that addresses this issue. Could you please review it when you have a moment? Your feedback would be greatly appreciated!
Thank you!
Thanks for the PR. I checked our CI and the fix did run the additional tests. Thanks for the PR! I'll close this issue as it is now merged.
Related https://github.com/spring-guides/gs-spring-boot/issues/20
HelloControllerIT (integration test) doesn't run. HelloControllerTest runs. The resolution to issue linked above is not correct.
Dir listing - src\test\java\learn\helloworld\HelloControllerIT.java
E:\coding\spring\springboot\helloworld>dir /s /b src E:\coding\spring\springboot\helloworld\src\bkp E:\coding\spring\springboot\helloworld\src\main E:\coding\spring\springboot\helloworld\src\test E:\coding\spring\springboot\helloworld\src\bkp\HelloControllerTest.java E:\coding\spring\springboot\helloworld\src\bkp\HelloworldApplicationTests.java E:\coding\spring\springboot\helloworld\src\main\java E:\coding\spring\springboot\helloworld\src\main\resources E:\coding\spring\springboot\helloworld\src\main\java\learn E:\coding\spring\springboot\helloworld\src\main\java\learn\helloworld E:\coding\spring\springboot\helloworld\src\main\java\learn\helloworld\HelloController.java E:\coding\spring\springboot\helloworld\src\main\java\learn\helloworld\HelloworldApplication.java E:\coding\spring\springboot\helloworld\src\main\resources\application.properties E:\coding\spring\springboot\helloworld\src\main\resources\static E:\coding\spring\springboot\helloworld\src\main\resources\templates E:\coding\spring\springboot\helloworld\src\test\java E:\coding\spring\springboot\helloworld\src\test\java\learn E:\coding\spring\springboot\helloworld\src\test\java\learn\helloworld E:\coding\spring\springboot\helloworld\src\test\java\learn\helloworld\HelloControllerIT.java
MVN test output
E:\coding\spring\springboot\helloworld>mvnw test [INFO] Scanning for projects... [INFO] [INFO] --------------------------< learn:helloworld >-------------------------- [INFO] Building helloworld 0.0.1-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ helloworld --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 1 resource [INFO] Copying 0 resource [INFO] [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ helloworld --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ helloworld --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory E:\coding\spring\springboot\helloworld\src\test\resources [INFO] [INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ helloworld --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ helloworld --- [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.751 s [INFO] Finished at: 2020-10-01T23:05:11+05:30 [INFO] ------------------------------------------------------------------------
MVN test post renaming - output extract
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 10.242 s - in learn.helloworld.HelloControllerITest 2020-10-01 23:09:35.938 INFO 6556 --- [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor' [INFO] [INFO] Results: [INFO] [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 17.408 s [INFO] Finished at: 2020-10-01T23:09:36+05:30 [INFO] ------------------------------------------------------------------------