Skip to content

0.9 : Refactoring

Compare
Choose a tag to compare
@agourlay agourlay released this 02 Sep 10:37
· 2794 commits to master since this release

This release contains several important internal refactorings that were necessary to fight the inherent complexity of a growing software.

A glimpse under the hood

Those internal refactorings were especially meant:

  • to ease the design of custom steps by notably introducing the RunState concept to propagate the context
  • to start the ground work to remove String as an universable input for the HttpDsl by introducing a new typeclass based abstraction called BodyInput
  • to offer different internal http clients in the future

All those changes will hopefully ease the introduction of new features in future releases.

This major version contains a couple of breaking changes which notably impact users relying on some helpers to build custom HTTP/JSON steps.

Breaking changes

  • The HttpService as been simplified, instead of exposing one function per HTTP verb it promotes requestEffect as an entry point. The HttpRequest is built using the usual DSL.
def create_customer = EffectStep(
    title = "create new customer",
    effect = http.requestEffect(
      request = HttpRequest.post("/customer").withPayload("someJson"),
      expectedStatus = Some(201)
      extractor = RootExtractor("customer")
    )
  )
  • whiteListing renamed to whitelisting in the DSL.
  • SimpleStepAssertion renamed to GenericAssertion
  • JsonMapper moved from com.github.agourlay.cornichon.core to com.github.agourlay.cornichon.resolver
  • HttpService session keys moved to com.github.agourlay.cornichon.http.HttpService.SessionKeys._
  • upgrade to Scalatest 3.0.0 (might be problematic if you were mixing other tests)

New features

  • placeholders in steps's titles are now automatically resolved - #19
  • graphQL JSON formatted strings can be used as input for the http steps - #60
import com.github.agourlay.cornichon.json.CornichonJson._

When I post("/superheroes").withBody(
  gql"""
          {
            name: "Scalaman"
            city: "Berlin"
          }
   """)
  • new containsString assertion on body - #85
body.path("city").is("Gotham city")
body.path("city").containsString("Gotham")
  • baseUrl can be overridden at the step level by passing the full URL - #84
  • add support for targetting element in a root array via JsonPath - #90
body.path("$[2]")

Misc

As always this release also contains various small improvements:

  • make the error reporting as clear as possible
  • documentation and examples