Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

BDD with JUnit

 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • 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.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • 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
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic