未解析的超类型:org.junit.rules.ExternalResource 将 MockWebServer 与 Junit 5 一起使用时
unresolved supertypes: org.junit.rules.ExternalResource when using MockWebServer with Junit 5
我正在使用来自 okhttp3
的 MockWebServer
dependencies {
testImplementation "org.junit.jupiter:junit-jupiter-api:5.5.2"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.5.2"
testImplementation "org.junit.jupiter:junit-jupiter-migration-support:5.0.0-M4"
testImplementation "junit:junit:4.12"
testImplementation "com.squareup.okhttp3:mockwebserver:4.2.1"
}
当我尝试使用此代码时:
mockwebserver.enqueue(MockResponse().setResponseCode(HttpURLConnection.HTTP_OK))
我收到错误:
e: Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
class okhttp3.mockwebserver.MockWebServer, unresolved supertypes: org.junit.rules.ExternalResource
我找到了 this 个对话,但它对解决问题没有帮助。
您使用了错误的人工制品。正确的在这里:https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-migrationsupport
也有对应的版本5.5.2
可能还有其他问题,但这是首先要解决的问题。
我正在使用来自 okhttp3
dependencies {
testImplementation "org.junit.jupiter:junit-jupiter-api:5.5.2"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.5.2"
testImplementation "org.junit.jupiter:junit-jupiter-migration-support:5.0.0-M4"
testImplementation "junit:junit:4.12"
testImplementation "com.squareup.okhttp3:mockwebserver:4.2.1"
}
当我尝试使用此代码时:
mockwebserver.enqueue(MockResponse().setResponseCode(HttpURLConnection.HTTP_OK))
我收到错误:
e: Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath: class okhttp3.mockwebserver.MockWebServer, unresolved supertypes: org.junit.rules.ExternalResource
我找到了 this 个对话,但它对解决问题没有帮助。
您使用了错误的人工制品。正确的在这里:https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-migrationsupport 也有对应的版本5.5.2
可能还有其他问题,但这是首先要解决的问题。