Quick start
Installation
Cornichon is available for Scala 2.13 & Scala 3.
The library is compatible with SBT and Mill.
// SBT
libraryDependencies += "com.github.agourlay" %% "cornichon-test-framework" % "0.23.0" % Test
testFrameworks += new TestFramework("com.github.agourlay.cornichon.framework.CornichonFramework")
// Mill
object test extends Tests {
def ivyDeps = Agg(ivy"com.github.agourlay::cornichon-test-framework:0.23.0")
def testFrameworks = Seq("com.github.agourlay.cornichon.framework.CornichonFramework")
}
Your first test
A Cornichon test is a class extending CornichonFeature and implementing the required feature function. In SBT, these classes live inside src/test/scala and can be run using sbt test.
A feature can have several scenarios which in turn can have several steps.
import com.github.agourlay.cornichon.CornichonFeature
class CornichonExamplesSpec extends CornichonFeature {
def feature = Feature("Checking google"){
Scenario("Google is up and running"){
When I get("http://google.com")
Then assert status.is(302)
}
}
}
Scala 3 braceless syntax
When using Scala 3, you can take advantage of significant indentation to drop the curly braces, resulting in a style closer to Cucumber/Gherkin:
import com.github.agourlay.cornichon.CornichonFeature
class CornichonExamplesSpec extends CornichonFeature:
def feature = Feature("Checking google"):
Scenario("Google is up and running"):
When I get("http://google.com")
Then assert status.is(302)
Both styles are equivalent; choose whichever your team prefers.
Failure modes
- A
featurefails if one or morescenariosfail. - A
scenariofails if at least onestepfails. - A
scenariowill stop at the first failed step encountered and ignore the remainingsteps.
Next steps
- DSL — full reference of available steps
- Understanding Test Output — how to read failure messages
- Feature Options — configure test execution
- Common Patterns — recipes for real-world testing scenarios