ITV / scala-pact

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

PactForger creates a stub server for every test #190

Closed jbwheatley closed 3 years ago

jbwheatley commented 3 years ago

We should add an easy option to forge a pact without running any consumerTests against the stubber because every test creates a http client and server, regardless of whether any integration testing is being done

jbwheatley commented 3 years ago

it should be possible to rewrite PactForgerSuite so that it has one global stubber and http client for all the tests in that suite.

jbwheatley commented 3 years ago

on further inspection this is a bad first issue

solarmosaic-kflorence commented 3 years ago

@jbwheatley it seems like just allowing more flexibility around the standing up and shutting down of the pact stub server would help with this. Currently you have to do ScalaPactDescription.runConsumerTest, which means right now you have to do all of your tests inside of one test block in ScalaTest if you don't want to stand up a stub server for every single test. If this was refactored instead to be ScalaPactDescription.startServer, which could start up the pact stub server, write out pact files, as it currently does, and wait for the server to be ready... but instead of executing a test it would just return the IPactStubber. Then tests can be run at will, and when they are done server.shutdown() can be called. This would fit in really nicely with ScalaTests beforeAll/afterAll functionality.

jbwheatley commented 3 years ago

@solarmosaic-kflorence yup, this is very similar to what I started implementing on a branch a while ago, but got distracted by other things so never got around to finishing it. Its still on my radar though

solarmosaic-kflorence commented 3 years ago

I may be able to help out with this in the next few weeks as I will be off work :)