Using Spring Boot 2.2.6.RELEASE, and without any other changes to my project, I upgraded JUnit dependency to 5.6.1. After doing so, tests annotated with @SpringBootTest
no longer run, and produce error:
Execution failed for task ':project-name:test'.
> No tests found for given includes: [io.orgname.service.ServiceTest](filter.includeTestsMatching)
````
Non-integration tests that are just annotated with `@Test` do work normally
Environment:
- Java 11
- Spring Boot 2.2.6.RELEASE
- JUnit 5.6.1
- Gradle 6.2.2
**Comment From: snicoll**
Can you please share a small build that showcases how you’ve overrides the junit version?
**Comment From: charlesritchea**
I've seen the same. Spring includes a specific version of JUnit (5.5.2?) and I saw a response somewhere that they don't support any other version
**Comment From: snicoll**
I don’t know what you are referring to @charlesritchea and that statement is inaccurate. There was a discussion on the junit tracker yesterday where [I shared a working example](https://github.com/junit-team/junit5/issues/2169#issuecomment-604361608) with JUnit 5.6 and Spring Boot 2.2. Anyway, we can resume this once the reporter has shared a sample.
**Comment From: austinarbor**
I'm having a hard time reproducing with an MVP, but it's happening every time in my own project. I'll see if I can get a working MVP later today
**Comment From: austinarbor**
@snicoll it may be related to that ticket you linked above, here is a snapshot of my gradle dependencies: variables below are defined as:
- springVersion: 2.2.6.RELEASE
- junitVersion: 5.6.1
- mockitoVersion: 3.3.3
```groovy
plugins {
id 'org.springframework.boot' version "${springVersion}"
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web") {
exclude module: "spring-boot-starter-tomcat"
}
implementation "org.springframework.boot:spring-boot-starter-undertow"
implementation "org.springframework.boot:spring-boot-starter-data-jpa"
implementation "org.springframework.boot:spring-boot-starter-security"
implementation "org.flywaydb:flyway-core"
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
testImplementation "org.mockito:mockito-core:${mockitoVersion}"
testImplementation "org.mockito:mockito-junit-jupiter:${mockitoVersion}"
testImplementation "org.junit.jupiter:junit-jupiter-api:${junitVersion}"
testImplementation("org.springframework.boot:spring-boot-starter-test") {
exclude module: "android-json"
}
testImplementation "org.springframework.security:spring-security-test"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
}
Comment From: snicoll
Yes, indeed. You are overriding individual artifacts so it's the exact same problem. Please refer to the gradle plugin documentation to learn more about proper version overriding.
Removing the ${junitVersion}
everywhere and adding ext['junit-jupiter.version'] = '5.6.1'
should do the trick.
Comment From: austinarbor
Looks like that resolved it, thanks for the help
Comment From: sbrannen
You may also find this related topic on Stack Overflow useful.