• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

BDD with JUnit

 
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi.
Recently, I'm trying to dig more in the agile development, tesing, continuous integration.
I have been reading about "Behaviour Driven Development"
I found a library called: jBehave
Why we need jBehave? why we can't use JUnit or TestNG for BDD?
Thanks.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
John,
You can use plain JUnit or TestNG. JBehave is designed to make things easier. For example, it looks like JBehave uses behavior/story language.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
John, the most visible difference between BDD and TDD is in the vocabulary and people have written tools such as JBehave to reflect that. Whereas in JUnit 3.x we used to identify tests with the "test" prefix in a method name, in JBehave you identify them with "should".

In other words, tools such as JBehave or JDave just give you a different "language" to express your tests (or behavior definitions, or specifications) with. You can do BDD with JUnit - you just have to sprinkle the word "test" around your behavior definitions.
 
Hussein Baghdadi
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Lasse Koskela:
Whereas in JUnit 3.x we used to identify tests with the "test" prefix in a method name, in JBehave you identify them with "should".


Lasse,
Any reason you didn't mention JUnit 4?
For a project, do you suggest to employ both libraries (JUnit and JBehave for example), or to use only one?
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by John Todd:
Any reason you didn't mention JUnit 4?


In JUnit 4 you don't need to prefix your test methods' names with anything. As I was referring to prefixes like "testXxx" and "shouldXxx", it just didn't feel necessary to mention JUnit 4.

Originally posted by John Todd:
For a project, do you suggest to employ both libraries (JUnit and JBehave for example), or to use only one?


Yes and yes.

There's value in keeping the setup simple - thus, use just one.
There's value in using the best tool for the job - thus, use both if you feel like it.

In other words, there's no one correct answer to this.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic