Recipe 17Use Cucumber with Java via Cucumber-JVM

Problem

You need to test Java code using Cucumber syntax. You’d like to write your step definitions in pure Java, without bringing Ruby into the mix. And you need to connect it to your existing set of Java IDE and build tools.

Ingredients

  • Cucumber-JVM,[102] a pure-Java (no Ruby) implementation of Cucumber

  • IntelliJ IDEA Community Edition,[103] the open source edition of the beloved Java IDE

  • JUnit[104] to serve as the test harness

  • Maven[105] for dependency management

Solution

There are a few different ways to use Cucumber to test code written for the Java platform. The simplest is to use JRuby, an implementation of Ruby written in Java. But it’s not the best fit for every project; it has ...

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.