Configuring localhost instance

210 views
Skip to first unread message

Syed Raza

unread,
Feb 1, 2021, 3:55:22 AM2/1/21
to wiremock-user
Dear all,
I'm running the standalone Wiremock on my localhost and connecting to it from within my program (cucumber JVM tests) using WireMock.configureFor(localhost, port). It is working fine and can connect to the WireMock instance. However, I realised the client can also connect to the local WireMock instance without configuring i.e. without WireMock.configureFor(localhost, post). And I can also connect to the instance from outside program like Postman.

Could you please tell me why the client can connect to the localhost wiremock instance even without configuring? Is configuring only required for remote instance?

I refer to this paragraph in the documentation:
Configuring WireMock using the Java client

The WireMock Java API can be used against a running server on a different host if required. If you’re only planning to configure a single remote instance from within your program you can configure the static DSL to point to it:

WireMock.configureFor("my.remote.host", 8000); // or for HTTPS WireMock.configureFor("https", "my.remote.host", 8443);

Look forward to hearing from you.

Many thanks,
Waqas

Tom Akehurst

unread,
Feb 1, 2021, 5:13:40 AM2/1/21
to wiremock-user
If you're running WireMock via the JUnit rule, this will call configureFor(...) after the server starts, so you don't need to do it explicitly. You need to call it yourself if a) you're talking to a remote instance, or b) you've created the WireMock server yourself and need to tell the static DSL which port to find it on.

Having said that, it's usually best to use the instance DSL directly on your WireMockServer or WireMockRule object, as this makes a direct Java call rather than calling the HTTP API so it'll be a bit faster.

Reply all
Reply to author
Forward
Message has been deleted
0 new messages