jbwheatley / pact4s

Apache License 2.0
29 stars 11 forks source link

Support multiple providers in a single test #118

Closed gaeljw closed 6 months ago

gaeljw commented 2 years ago

For some cases, it could be nice to support multiple providers in a single test, as what is possible with Pact JVM and JUnit: https://github.com/pact-foundation/pact-jvm/blob/master/consumer/junit/src/test/java/au/com/dius/pact/consumer/junit/pactproviderrule/PactMultiProviderTest.java.

Looking at the code, it seems to me that one way to achieve this would be to provide a new trait similar to BasePactForgerResourcesForPlatform that defines a list of pacts rather than a single one:

trait BasePactForgerResourcesForPlatformMultiProvider[Pact <: BasePact] extends BasePactForgerResources {

  // def pact: Pact
  def pacts: Seq[Pact]

  ...

}

The existing BasePactForgerResourcesForPlatform could actually be inheriting BasePactForgerResourcesForPlatformMultiProvider with a sequence of a single pact to avoid too much code duplication.

Then this could be implemented "on demand" for each test framework (scalatest/munit/weaver).

Any thought on this?

gaeljw commented 6 months ago

I believe https://github.com/jbwheatley/pact4s/pull/624 covers the initial need behind this feature request.