Recipe 20Test Scala Code

Problem

You want to test Scala code from Cucumber.

Ingredients

  • Cucumber-JVM,[125] a Cucumber implementation in Java that can test code in any JVM language

  • Cucumber-Scala, support for Scala that ships with Cucumber-JVM

  • JUnit[126] for running your tests

  • Maven[127] for installing these libraries

Solution

Cucumber-JVM is an implementation of the Cucumber test framework written in Java. With it, you can test code written in Scala and other popular JVM languages.

In this recipe, we’re going to create a simple stock broker class in Scala and test it from Cucumber.

Setup

First, download and extract the latest Maven 3 .zip file for your platform.[128] Next, create pom.xml, the build script for your project, with the following ...

Get Cucumber Recipes now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.