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
andAssertion
steps now consume aScenarioContext
instead of aSession
.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 usefillPlaceholders
in theScenarioContext
.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 toCornichonJson.parseDslJsonUnsafe
.a
DslJson
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 tocom.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
- thread safe date matchers #259 by @michalmela
β‘οΈ 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