-1

I am trying to verify the pact contract on the provider side, and would like to set up the real service first and then get the service port. So basically, I want to do something below:

  @TestTarget
  public final Target target = new HttpTarget(port);

  @Before
  public void setUpService() {
    port = 8090;
  }

Is there a way to do it?

1 Answers1

1

Unfortunately the HttpTarget target is acquired before any of the methods annotated with @Before are executed, and it has final fields, so you won't be able to change the port.

What you can do is implement your own test target that allows the port to be changed. Then you could set the port in a @Before method.