Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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: 41086
848
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.
 
You got style baby! More than this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic