71

I have read somewhere that JBehave is actually the Java equivalent of Cucumber, whereas Cucumber is based on Ruby.

Can someone describe the differences between them provide links that do?

Sled
  • 18,541
  • 27
  • 119
  • 168
Manoj
  • 913
  • 1
  • 7
  • 9

4 Answers4

107

JBehave and Cucumber are completely different frameworks, although meant for the same purpose: acceptance tests. They are based around stories (JBehave) or features (Cucumber). A feature is a collection of stories, expressed from the point of view of a specific project stakeholder. In your tests, you are referring to the stories, typically via regular expression matching.

JBehave is a pure Java framework whereas Cucumber is based on Ruby. Both are very mature frameworks. You can use Cucumber from Java via the Cuke4Duke Maven plugin from Maven, but there is still a language mismatch as it continues to use Ruby internally and you will need to install this language and its infrastructure (so-called 'gems') on the machine that runs your tests. This can be brittle and the language mismatch complicates both debugging and impedes performance of your tests. There is now a pure Java implementation of Cucumber which is called Cucumber-JVM. As of December 2011, it's not released yet, but perfectly usable (edit: version 1.0.0 was released on March 27th, 2012). This new framework is very similar to JBehave as both have native JUnit support.

The following is a comparison of Cucumber-JVM and JBehave.

Similarities:

  • JUnit support out of the box
  • Pure Java
  • Fast
  • Easy to use

Pros/Cons of JBehave:

  • Pro Very good documentation
  • Pro Pretty good HTML formatting of test results
  • Con Only supports stories, not features

Pros/Cons of Cucumber-JVM:

  • Pro Supports features
  • Con Doesn't support parallel JUnit tests. Will however work with parallel Maven 3 builds.
  • Con Lacking documentation
  • Con No pretty HTML formatting of test results, other than JUnit's own formatting (edit: Cucumber-JVM now does support HTML output)

If you are on a Java project, I would recommend either JBehave (if you are looking for great documentation) or Cucumber-JVM (if the support of features instead or stories is important to you).

I tried both frameworks and went for for Cucumber-JVM.

Sled
  • 18,541
  • 27
  • 119
  • 168
cgleissner
  • 1,127
  • 1
  • 6
  • 3
  • 1
    Hi cgleissner, Thank you Very much. Indeed a detailed report helped me in understanding. Thanks again for your efforts. +1 Regards, – Manoj Dec 08 '11 at 19:21
  • 11
    I had to switch from Cucumber to JBehave because Cucumber-JVM is not supported by Sonar tool. – GrayR Dec 20 '12 at 22:02
  • nice answer, well explained – ravikumar Jul 18 '14 at 12:51
  • 1
    Why is it a disadvantage that JBehave has stories instead of features? JBehave stories and Cucumber features are both collections of Scenarios, so they're functionally identical. "Story" doesn't seem like as good a name for what it is, but that's not a big deal. – Dave Schweisguth Sep 02 '16 at 15:03
  • Can any one share the sample JBehave project for may be login page ? I want to learn but as don't have time, initially want to go through examples directly and later will go through the documentations. Thanks! – Paresh Oct 06 '16 at 02:44
  • cucumber-java documentation is good.. there are few online books free for download .. – Jags Sep 29 '17 at 23:09
  • 1
    There is a HTML output in Cucumber-JVM, but JBehave let you fully customize the report. Freemarker templates allows you to use your own JS, CSS, images, etc. – Mateusz Was Oct 27 '17 at 15:27
  • would JBehave support the cons of Cucumber? – Ashok kumar Ganesan Jan 20 '20 at 05:53
  • Cucumber support parallel execution since version 4.0.0: https://cucumber.io/docs/guides/parallel-execution/#junit – Ofir Meguri May 19 '20 at 18:40
  • You say that Cucumber-JVM divides a story into features, and this is a plus for Cucumber-JVM. I would argue that JBehave divides a story into scenarios, and this point is moot. – Jason Hendriks Dec 09 '20 at 20:13
4

Cucumber JVM is the Java implementation of the popular Cucumber BDD tool, as mentioned in the above answers.

JBehave has many additional configurations to fine-tune a BDD tool as per your preferences. But with those configurations come a great complexity too. At the end of the day, we are going Agile and we love being Lean in our work. The question you should ask from youself is whether these complex configurations add any significant value to your workflow. I have seen people doing BDD even without a powerful tool like Cucumber or JBehave. Some creates their own tools as well. My observation was, if you need a BDD tool, Cucumber has almost all the power you need.

For more insights, you may read this blog article written by me: JBehave Vs Cucumber JVM: Comparison and Experience Sharing

P. S. I feel like Stackoverflow is not the best community to ask subjective questions on tools. Anyways hope this discussion will be useful for someone.

Thilina Ashen Gamage
  • 1,367
  • 1
  • 12
  • 21
  • 1
    Asking about differences is not a subjective question on tools. Differences are something objective. Asking about advantages and disadvantages may be subjective, but that was definitely not part of the question - although it was part of some answers - e.g. of yours. – yaccob Oct 13 '18 at 19:35
  • Nevertheless I find your opinionated article on this topic a very good article! – yaccob Oct 13 '18 at 19:47
4

As the accepted answer states, JBehave is pure Java, whilst Cucumber is a generalised BDD framework that is implemented in different languages, and can be made available as a testing framework in various different contexts - see here https://docs.cucumber.io/installation/.

If you're looking to implement a BDD framework for a Java project, then your comparison should mainly be between JBehave and Cucumber-JVM (the pure Java implementation of Cucumber).

This following up-to-date reference from July 2017 compares JBehave and Cucumber-JVM, and indicates that cucumber-jvm is currently generally being preferred to JBehave (in terms of degree of current activity and usage). This includes Cucumber-JVM being more actively maintained:

https://medium.com/agile-vision/jbehave-vs-cucumber-jvm-comparison-and-experience-sharing-439dfdf5922d

The article also states in its conclusion that:

According to my understanding, JBehave is in the maturity phase of its life cycle, whereas Cucumber is still reaching the maturity level with cool new features day-by-day.

The article scores Cucumber-jvm more highly overall for the following aspects

  • Documentation and community
  • Features (see my note below)
  • Reports
  • Popularity, code quality and current activity on GitHub
  • Activity on StackOverflow

Note on features:

The article scores the Cucumber-JVM features more highly overall for the feature set that it compares, however the weighting that you may give to certain features will depend on your specific needs:

  • The article rates Cucumber-JVM higher for the following:

    • IDE plugin (syntax highlighting)
    • Formatting Flexibility
    • Lambda Expression support
  • The article rates JBehave higher for the following:

    • External Data support
    • Composite Steps (this is rated as having low support in Cucumber-JVM, with the following explanatory notes):
    • Composite Steps are not a feature of BDD/Gherkin Standard.

    • ... The major reason was, people who made use of this feature frequently ended up with messy automation code that was fragile and difficult to maintain.

  • The article rates jbehave and Cucumber-JVM the same for the following:

    • Backgrounds and Hooks
    • Binding to code (Annotations)

JBehave features:

https://jbehave.org/reference/stable/features.html

Chris Halcrow
  • 28,994
  • 18
  • 176
  • 206
2

No, Actually, Java equivalent of cucumber is Cucumber-JVM. You may also need to check this Link to understand the difference between these two famous BDD frameworks.

Karthikeyan
  • 2,634
  • 5
  • 30
  • 51