Shady Ragab
Shady Ragab

Reputation: 725

spring boot multiple tests classes but only is executed when mvn package the app

I have fresh spring boot application generated from https://start.spring.io/

My problem is the generated already Test class is the only one is executed even when I have added different test classes with the same annotaions as the generated one and located in the same package.

spring boot version is : 2.2.4

Upvotes: 0

Views: 633

Answers (1)

JArgente
JArgente

Reputation: 2297

I think that the problem could be because of the name of the test classes. By default maven only executes test in the clasees which follows this name convention: (In short the test class must starts or ends with Test word)

By default, the Surefire Plugin will automatically include all test classes with the following wildcard patterns:

"/Test*.java" - includes all of its subdirectories and all Java filenames that start with "Test". "/*Test.java" - includes all of its subdirectories and all Java filenames that end with "Test". "/*Tests.java" - includes all of its subdirectories and all Java filenames that end with "Tests". "/*TestCase.java" - includes all of its subdirectories and all Java filenames that end with "TestCase".

As you can see in

https://maven.apache.org/surefire/maven-surefire-plugin/examples/inclusion-exclusion.html

Upvotes: 1

Related Questions