aspose file tools*
The moose likes Testing and the fly likes BDD with JUnit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "BDD with JUnit" Watch "BDD with JUnit" New topic
Author

BDD with JUnit

Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

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

Joined: May 26, 2003
Posts: 30957
    
158

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
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.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

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

Joined: Jan 23, 2002
Posts: 11962
    
    5
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: BDD with JUnit