0

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

4
  • Does this answer your question? how to run all tests in a particular package with maven Commented Feb 3, 2020 at 12:06
  • 1
    Is not it the default behaviour that all test classes in the same package to be executed? I just want to run all classes without exclusions or inclusions. Commented Feb 3, 2020 at 12:12
  • can you mention the annotations and class declaration of your test class? e.g which other class it extends? Commented Feb 3, 2020 at 12:15
  • typical spring boot generated application from spring intializer.The answer provided by JARgente below is correct :) Commented Feb 3, 2020 at 12:29

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.