-
Notifications
You must be signed in to change notification settings - Fork 9.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot use MockWebServer with Junit 5? class file for org.junit.rules.ExternalResource not found #7987
Comments
OkHttp 5 alpha has a junit 5 module. https://github.com/square/okhttp/tree/master/mockwebserver-junit5 |
This is what fixed it for me:
Be sure you don't have any JUnit 4 dependencies lying around. |
Huh ok this worked; thought I had tried that combo but something must've gotten lost in the sauce. Using these dependencies my test now runs without error, thanks! |
You're welcome, glad I could help!
Il mar 22 ago 2023, 17:10 jasonlo87 ***@***.***> ha scritto:
… This is what fixed it for me:
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>mockwebserver3-junit5</artifactId>
<version>5.0.0-alpha.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>5.0.0-alpha.11</version>
<scope>test</scope>
</dependency>
Be sure you don't have any JUnit 4 dependencies lying around.
Huh ok this worked; thought I had tried that combo but something must've
gotten lost in the sauce.
Using these dependencies my test now runs without error, thanks!
—
Reply to this email directly, view it on GitHub
<#7987 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGDSLX5G43NDYH6Y72ZCGLXWTDXHANCNFSM6AAAAAA3V5WUHU>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Following all the internet wisdom and guides I'm unable to get MockWebServer to play nice w/ Junit 5.
What is the recipe for getting this to work correctly without and error like this?
final var mockUrl = this.mockWebServer.url("/").toString();
^
class file for org.junit.rules.ExternalResource not found
Gradle dependencies are as follows:
dependencies {
// Platforms
implementation platform(SpringBootPlugin.BOM_COORDINATES)
implementation platform('software.amazon.awssdk:bom:2.20.109')
// Spring Dependencies, Boot version is 2.6.9
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-webflux'
implementation group: 'org.springframework.retry', name:'spring-retry'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-aop'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-security'
// Misc 3rd Party Dependencies
implementation group: 'io.jsonwebtoken', name:'jjwt', version:'0.7.0'
implementation group: 'com.sun.mail', name: 'jakarta.mail'
implementation group: 'org.apache.httpcomponents', name:'httpclient'
implementation group: 'org.apache.commons', name: 'commons-lang3'
// Test Dependencies
testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test'
testImplementation group: 'org.mockito', name: 'mockito-core'
testImplementation group: 'com.squareup.okhttp3', name: 'mockwebserver', version: '4.11.0'
testImplementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '4.11.0'
}
test {
useJUnitPlatform()
}
The text was updated successfully, but these errors were encountered: