What are the differences between JBehave and Cucum

2019-03-09 05:53发布

问题:

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?

回答1:

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.



回答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.



回答3:

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.



回答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