Issue
I a project I am handling, I see these dependencies defined:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
But I can't understand why there are 2 artifacts for testing with Spring Boot, what is the difference between both of them? Maybe with the latter, I am also importing the former?
Solution
The spring-boot-starter-test
is an aggregated "starter pack" for libraries using often together for testing in Spring applications.
As stated in the latest version reference documentation, the spring-boot-starter-test
contains:
JUnit 5 (including the vintage engine for backward compatibility with JUnit 4)
Spring Test & Spring Boot Test - This is the
spring-boot-test
dependency)AssertJ, Hamcrest, Mockito, JSONassert, and JsonPath.
You can remove the explicit definition of the spring-boot-test
dependency.
Answered By - Nikolas Charalambidis