cornichon v0.18.0 Release Notes

Release Date: 2019-08-29 // over 4 years ago
  • πŸš€ There are quite a few breaking changes in this release, however it should only impact users who are:

    • defining custom steps
    • using the cornichon-kafka module

    🍱 If you are only using the built-in DSL you should be fine 🀞

    🍱 Deterministic tests 🎲

    πŸš€ The goal of this release is to have deterministic runs via a fixed seed.

    class DeterministicFeature extends CornichonFeature { override lazy val seed: Option[Long] = Some(1L) def feature =Feature("demo deterministic feature") { Scenario("always the same") { Given I save("my-uuid" -\> "\<random-uuid\>") Then assert session\_value("my-uuid").is("bb1ad573-19b8-9cd8-68fb-0e6f684df992") } } } 
    

    πŸ‘€ This test will be valid as long as the fixed seed stays the same.

    πŸ‘€ It is also possible to pass the seed via a command argument and not change the code (only in cornichon-test-framework).

    testOnly *DeterministicFeature -- "always the same" "--seed=1"
    

    πŸ‘€ On a failure the initial seed will be provided in the error reporting, enabling you to replay the exact same test even if it contains a source of randomness such as:

    • randomized placeholders (random-uuid, random-string, random-boolean etc.)
    • cornichon-check value generators & transitions
    • custom steps using ScenarioContext.randomContext
    • RandomMapper as extractor

    πŸ’₯ breaking changes

    EffectStep and Assertion steps now consume a ScenarioContext instead of a Session.

    example for the effect field:

    effect: Session⇒ Either[CornichonError, Session] effect: ScenarioContext ⇒ Either[CornichonError, Session]
    

    ScenarioContext is a new concept encapsulating all the states of a given scenario.

    trait ScenarioContext { val randomContext: RandomContextval session: Session// uses randomContext to resolve randomized placeholdersdef fillPlaceholders(input: String): Either[CornichonError, String] }
    

    πŸš€ disclaimer: mutation still exists within RandomContext - it will be tackled in a future release.

    placeholderResolver is now gone, to resolve placeholders use fillPlaceholders in the ScenarioContext .

    the underlying Step contract was changed to accommodate the propagation of state.

    trait Step { def run(engine: Engine)(initialRunState: RunState): Task[(RunState, FailedStep Either Done)] }
    

    to

    trait Step { val stateUpdate: StateT[Task, RunState, FailedStep Either Done] def runStep(runState: RunState): Task[(RunState, FailedStep Either Done)] = stateUpdate.run(runState) }
    

    πŸ“œ CornichonJson.parseJsonUnsafe has been renamed to CornichonJson.parseDslJsonUnsafe .

    aDslJson String can either represent:

    - a JSON object
    - a JSON array
    - a JSON string
    - a datatable
    

    πŸ“œ If you want to parse regular JSON use CornichonJson.parseString .

    🚚 RandomContext was moved to com.github.agourlay.cornichon.core.RandomContext .

    various changes to the cornichon-kafka DSL #244 .

    0️⃣ Gzip is now enabled by default.

    0️⃣ http4s client is now the default http client, replacing akka-http client.

    • The configuration line useExperimentalHttp4sClient must be removed if you were using it as experimental client.

    - the akka dependency has been removed completely.

    πŸ‘€ check_model does not take a seed as an input anymore.

    πŸ‘Œ improvements

    πŸ‘€ deterministic run via fixed seed on the feature and command line argument.

    πŸ†• new matcher on JSON body to check that a field is present and not null.

    body.path("myKey").isNotNull
    

    🀑 the noisy stack trace appearing when shutting down servers in cornichon-http-mock is now gone.

    πŸ› bug fixes

    ⚑️ dependency updates

    • scala 2.12.9
    • http4s 0.20.10
    • pureConfig 0.11.1
    • monix 3.0.0-RC3
    • βœ… scalatest 3.0.8
    • caffeine 2.780
    • parboiled 2.1.8
    • 🚚 akka-http has been removed