I am migrating an existing project to boot. I created a brand new project using start.spring.io and copied over the source code, etc. Everything compiles, but when I do a 'mvn test' it compiles the classes but then only executes the default 'ApplicationTests' (created by start.spring.io).
Here's an excerpt from the maven output:
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ pendview ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\dev\pendview2\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ pendview ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 26 source files to C:\dev\pendview2\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.15:test (default-test) @ pendview ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
What's even stranger is that if I pass '-Dtest=TestAuthController' then it does run that specific unit test:
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ pendview ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 26 source files to C:\dev\pendview2\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.15:test (default-test) @ pendview ---
[INFO] Surefire report directory: C:\dev\pendview2\target\surefire-reports
(skipped output of AuthControllerTest for brevity)
-------------------------------------------------------
T E S T S
-------------------------------------------------------Results :
Tests run: 6, Failures: 0, Errors: 0, Skipped: 0
What am I doing wrong? Does spring boot setup a surefire config that I'm not conforming to?
Any help would be greatly appreciated! -Trey
Spring Boot configures the Surefire plugin to run all test classes that have a name ending with Test
or Tests
but not starting with Abstract
. You can see this configuration in the spring-boot-starter-parent
pom. If your test class is named TestAuthController
then it doesn't match this configuration. Renaming it to AuthControllerTest
or AuthControllerTests
should fix your problem.
Seems for me there is some issue with Maven surefire
plugin, when it doesn't detect tests, if your test class name doesn't end with Tests
suffix. :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With