A Scala implementation of CDC using the Pact standard
Scala Shell
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
example Bumped to 2.3.3-SNAPSHOT Aug 12, 2018
pact-spec-tests/src/test Tweaking Scalafmt settings. Apr 16, 2018
pacts WIP: Stubber is working with http4s18 Stub implementation. Tests brok… Apr 20, 2018
project Docs: updated setup, project-deps, and added standalone stubber detai… May 23, 2018
sbt-scalapact-nodeps Added test and case class for tuple Aug 1, 2018
sbt-scalapact-shared/src Added test and case class for tuple Aug 1, 2018
sbt-scalapact Added test and case class for tuple Aug 1, 2018
scalapact-argonaut-6-2/src Experimenting to make plugin with and without hard deps. Apr 17, 2018
scalapact-circe-0-8/src Experimenting to make plugin with and without hard deps. Apr 17, 2018
scalapact-circe-0-9/src Experimenting to make plugin with and without hard deps. Apr 17, 2018
scalapact-core Pact verify exits with 1 if zero tests are run. Aug 12, 2018
scalapact-docs Updated README and Changelog Aug 12, 2018
scalapact-http4s-0-16a/src Added support to missing http methods. Jul 26, 2018
scalapact-http4s-0-17/src Added support to missing http methods. Jul 26, 2018
scalapact-http4s-0-18/src Added support to missing http methods. Jul 26, 2018
scalapact-scalatest Added test and case class for tuple Aug 1, 2018
scalapact-shared/src Added support to missing http methods. Jul 26, 2018
scalapact-standalone-stubber Docs: updated setup, project-deps, and added standalone stubber detai… May 23, 2018
scripts Tweaked release script, moved version back to 2.3.0-SNAPSHOT. May 3, 2018
ssl Applied the patch - needs review and testing. Dec 4, 2017
tests-with-deps/src/test/scala/com/itv Fix port reuse in tests. Jun 28, 2018
.gitignore Updated release process so it should now work correctly. Oct 4, 2017
.sbtopts Fix race condition between obtaining free port and binding to it. Jun 28, 2018
.scalafmt.conf Tweaking Scalafmt settings. Apr 16, 2018
CHANGELOG.md Docs site tweaks and updated all md files to refer to the website. Oct 25, 2016
CONTRIBUTING.md Docs site tweaks and updated all md files to refer to the website. Oct 25, 2016
LICENCE.md Updated licence link. Apr 11, 2018
README.md Updated README and Changelog Aug 12, 2018
SSL_README.md Applied the patch - needs review and testing. Dec 4, 2017
build.sbt Bumped to 2.3.3-SNAPSHOT Aug 12, 2018

README.md

Scala-Pact

A Consumer Driven Contract testing library for Scala and ScalaTest that follows the Pact standard.

Scala-Pact is intended for Scala developers who are looking for a better way to manage the HTTP contracts between their services.

Latest version is 2.3.2

Scala-Pact now has two branches based on SBT requirements.

SBT 1.x compatible (Latest 2.3.2)

The all development going forward begins at 2.3.x and resides on the master branch. For the sake of the maintainer's sanity, version 2.3.x and beyond will only support Scala 2.12 and SBT 1.x or greater.

SBT 0.13.x compatible (Latest 2.2.5)

The reluctantly maintained EOL maintenance version of Scala-Pact lives on a branch called v2.2.x. These versions support Scala 2.10, 2.11, and 2.12 but are limited by only supporting SBT 0.13.x.

More information

Please visit our official documentation site for more details and examples.

There is also an example project setup for reference.

Getting setup

Scala-Pact goes to great lengths to help you avoid / work around dependency conflicts. This is achieved by splitting the core functionality out of the library requirements which are provided separately. This allows you to align or avoid conflicting dependencies e.g. If your project uses a specific version of Circe, tell Scala-Pact to use Argonaut! One big change between 2.2.x and 2.3.x is that dependencies are now provided by TypeClass rather than just static linking. Please refer to the example setup.

You're using SBT 1.x:

Add the following lines to your build.sbt file to setup the test framework:

import com.itv.scalapact.plugin._

enablePlugins(ScalaPactPlugin)
        
libraryDependencies ++= Seq(
  "com.itv"       %% "scalapact-circe-0-9"     % "2.3.2" % "test",
  "com.itv"       %% "scalapact-http4s-0-18"   % "2.3.2" % "test",
  "com.itv"       %% "scalapact-scalatest"     % "2.3.2" % "test",
  "org.scalatest" %% "scalatest"               % "3.0.5" % "test"
)

Add this line to your project/plugins.sbt file to install the plugin:

addSbtPlugin("com.itv" % "sbt-scalapact" % "2.3.2")

This version of the plugin comes pre-packaged with the latest JSON and Http libraries. Thanks to the way SBT works, that one plugin line will work in most cases, but if you're still having conflicts, you can also do this to use your preferred libraries:

 libraryDependencies ++= Seq(
   "com.itv" %% "scalapact-argonaut-6-2" % "2.3.2",
   "com.itv" %% "scalapact-http4s-0-16a" % "2.3.2"
 )
 
 addSbtPlugin("com.itv" % "sbt-scalapact-nodeps" % "2.3.2")

In you're test suite, you will need the following imports:

The DSL/builder import for Consumer tests:

  import com.itv.scalapact.ScalaPactForger._

Or this one for Verification tests:

  import com.itv.scalapact.ScalaPactVerify._

You'll also need to reference the json and http libraries specified in the build.sbt file:

  import com.itv.scalapact.circe09._
  import com.itv.scalapact.http4s18._

Alternatively, these are also valid if you prefer:

  import com.itv.scalapact.json._
  import com.itv.scalapact.http._

You're using SBT 0.13.x:

Add the following lines to your build.sbt file to setup the test framework:

import com.itv.scalapact.plugin._

enablePlugins(ScalaPactPlugin)
        
libraryDependencies ++= Seq(
  "com.itv"       %% "scalapact-circe-0-9"     % "2.2.5" % "test",
  "com.itv"       %% "scalapact-http4s-0-18-0" % "2.2.5" % "test",
  "com.itv"       %% "scalapact-scalatest"     % "2.2.5" % "test",
  "org.scalatest" %% "scalatest"               % "3.0.5" % "test"
)

Add these lines to your project/plugins.sbt file to install the plugin:

libraryDependencies ++= Seq(
  "com.itv" %% "scalapact-argonaut-6-2"  % "2.2.5",
  "com.itv" %% "scalapact-http4s-0-16-2" % "2.2.5"
)

addSbtPlugin("com.itv" % "sbt-scalapact" % "2.2.5")

In you're test suite, you will need the following import for Consumer tests:

  import com.itv.scalapact.ScalaPactForger._

Or this one for Verification tests:

  import com.itv.scalapact.ScalaPactVerify._

Note that you can use different versions of Scala-Pact with the plugin and the testing framework, which can make Scala 2.10 compat issues easier to work around while we get the SBT 1.0 release sorted out.