ITV / scala-pact

A Scala implementation of CDC using the Pact standard
Other
108 stars 54 forks source link

Support async tests #203

Open solarmosaic-kflorence opened 3 years ago

solarmosaic-kflorence commented 3 years ago

The runConsumerTest method is currently synchronous, because all of our code is asynchronous this means we have to use Await.result here instead of (in our case) ScalaTest's AsyncWordSpec. It would be better if this method were asynchronous by nature, and both a synchronous and asynchronous API were supported. (e.g. runConsumerTestAsync).

solarmosaic-kflorence commented 3 years ago

Likewise for setupProviderState it would be nice to support asynchronous setting up of state.

solarmosaic-kflorence commented 3 years ago

Actually, now that I understand how this works a little better, it seems like it would be best to just allow separating the standing up of the stub server from the shutting down of the stub server (for consumer tests). There should be different methods for starting and stopping it. That way it can be controlled either before and after each test or before and after all tests. This would allow for a more natural ScalaTest syntax (at least when using WordSpec).

Related to https://github.com/ITV/scala-pact/issues/190