2

I'm using MockWebServer from 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"
}

when I try to use this code:

    mockwebserver.enqueue(MockResponse().setResponseCode(HttpURLConnection.HTTP_OK))

I get the error:

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

I've found this conversation but it did not help to fix the problem.

kingston
  • 11,053
  • 14
  • 62
  • 116

1 Answers1

4

You are using the wrong artefact. The correct one is here: https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-migrationsupport It also has the corresponding version 5.5.2

There may still be other problems but that’s the first thing to fix.

johanneslink
  • 4,877
  • 1
  • 20
  • 37
  • Thank you. It does not fix the problem but that was wrong – kingston Dec 15 '19 at 09:32
  • I'm approving your answer even if my problem was different. When I wrote this question I simplified the code (that is very complex in the real app). I thought I had reported everything important but actually I was making a mistake: one of the the import was using `mockImplementation` instead of `testImplementation`. The `mock` prefix was there because I have a flavour called `mock`. So I was importing the migrationsupport library in one build and the mockwebserver library in another one. Anyway your answer is the correct answer for the question that I asked. – kingston Dec 16 '19 at 14:44