Question

I am trying to use wiremock 1.46 with junit-4.11 and i am following the examples on the wiremock website and when i try to use the following piece of code

stubFor(get(urlEqualTo("/my/resource"))
                .withHeader("Accept", equalTo("text/xml"))
                .willReturn(aResponse()
                    .withStatus(200)
                    .withHeader("Content-Type", "text/xml")
                    .withBody("<response>Some content</response>")));

i am getting the following errors

the method aResponse() is undefiened for the type
the method equalTo() is undefiened for the type
the method urlEqualTo() is undefiened for the type

i am guessing that this is happening because i need another JAR file for these but does anyone know what JAR files are needed for these methods?

Was it helpful?

Solution

I believe you just forgot

import static com.github.tomakehurst.wiremock.client.WireMock.*;

The methods you are trying to invoke are static methods of the WireMock type. They aren't static methods of your custom type. You either import as above, or invoke them with the qualified name of the type.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top