Agile Zone is brought to you in partnership with:

Meera has posted 70 posts at DZone. You can read more from them at their website. View Full User Profile

Is easyb Easy?

09.17.2008
| 41484 views |
  • submit to reddit

You can have as many givens, whens, and thens, with ands linking them within your Scenarios.

easyb supports the following syntax for should and ensure. Remember, you can also check that an exception is thrown by your code using the ensureThrows variant of the ensure closure; like we did in our 3rd scenario.

Here is a list of the should and ensure syntax:

And now finally, the verdict. Is easyb Easy? In my opinion, it was very

 What do you think? Give it a try, it is easy

Update: Jochen Bedersdorfer, commented that it would be interesting to see what happens when a test fails. So, here is what happens:

In my case, I changed the password for the Account. The scenario one was supposed to validate that the user name was "meera" and password was "password". When you run the same:

Buildfile: /Users/meerasubbarao/Development/easyb-samples/build.xml
init:
run.easyb.stores:
    [easyb] easyb is preparing to process 1 file(s)
    [easyb] Running login service test story (LoginServiceTest.story)
    [easyb] FAILURE Scenarios run: 3, Failures: 1, Pending: 0, Time Elapsed: 0.529 sec
    [easyb]     "the system returns a valid account" -- expected password1 but was password
    [easyb] 3 total behaviors run with 1 failure
    [easyb] easyb execution FAILED
BUILD SUCCESSFUL
Total time: 1 second

 

And within the Story.txt file, you will also see the output as such for the scenario which failed:

    scenario User enters valid credentials
      given user account already exists
      when user logins
      then the system returns a valid account [FAILURE: expected password1 but was password]

 

Published at DZone with permission of its author, Meera Subbarao.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Kode Ninja replied on Wed, 2008/09/17 - 7:02am

Meera, if you use the .groovy extension, then your stories should end in 'Story.groovy', not just '.groovy'.

So, your AccountServiceTest.groovy should actually be named AccountServiceTestStory.groovy

Cheers!

Kodeninja

Meera Subbarao replied on Wed, 2008/09/17 - 7:03am in response to: Kode Ninja

[quote=kodeninja]

So, your AccountServiceTest.groovy should actually be named AccountServiceTestStory.groovy

[/quote]

 Thanks so much, I will correct the post reflecting the same.

Meera Subbarao

Jochen Bedersdorfer replied on Wed, 2008/09/17 - 7:13pm

Would have been interesting to see when a test fails.

Apart from that, thank you for the smooth introduction to easyb

Meera Subbarao replied on Wed, 2008/09/17 - 7:28pm in response to: Jochen Bedersdorfer

[quote=beders]

Would have been interesting to see when a test fails.

 [/quote]

Great, idea. Never thought about the same. I will update the post.

Meera Subbarao

David Sills replied on Thu, 2008/09/18 - 11:04am

Meera:

 What an interesting post! I wonder how much of this can be actually laid out by the user, perhaps sort of Fit style, to enable more effective Acceptance TDD? Just a thought.

David Sills

 

Meera Subbarao replied on Thu, 2008/09/18 - 11:12am in response to: David Sills

[quote=davidsills]

I wonder how much of this can be actually laid out by the user, perhaps sort of Fit style, to enable more effective Acceptance TDD? Just a thought.

[/quote]

I think most of it can be written by the user, the developer just needs to fill in the code. 

Meera Subbarao

Meera Subbarao replied on Thu, 2008/09/18 - 11:19am in response to: Jochen Bedersdorfer

[quote=beders]

Would have been interesting to see when a test fails.

[/quote]

The article has been updated for a failing scenario as well.

Meera Subbarao

Jochen Bedersdorfer replied on Thu, 2008/09/18 - 11:35am in response to: Meera Subbarao

Thank you.

I like the test result. It clearly tells you what was wrong and the description can almost be used directly in a bug tracking system.

Nice

Tushar Joshi replied on Wed, 2008/10/01 - 5:31am

File must end with Story.groovy error 

I tried EasyB in NetBeans and it continuously gave me the error that the file must end with Story.groovy

When searched for similar issue in EasyB Users list I came across the issue of folder having spaces in the names.  My netbeans project is inside NetBeansProject folder which is by default made in the My Documents folder which has a space.  I moved the EasyB project to a folder having no space and it worked.

 Just adding here for people who may face the same problem with Netbeans. 

 

with regards

Tushar 

Meera Subbarao replied on Wed, 2008/10/01 - 8:45am in response to: Tushar Joshi

[quote=tusharvjoshi]

When searched for similar issue in EasyB Users list I came across the issue of folder having spaces in the names.  My netbeans project is inside NetBeansProject folder which is by default made in the My Documents folder which has a space.  I moved the EasyB project to a folder having no space and it worked.

[/quote]

Thanks for sharing, Tushar.

Meera Subbarao

Syed Abu replied on Tue, 2009/04/28 - 10:27am

hey Meera

 Thank for doing a good job. In easyb  i am getting this erxception

 unable to resolve class LoginServiceImpl

 Actually i just copied ur code then slightly changed  and trying to run it.

 and one more thing that i am thinking that the problem is in story fil. The following is my story file code

 scenario "User enters valid credentials", {
 given "user account already exists",{      
       loginService = new LoginServiceImpl()
 }
 when "user logins",{
 account = loginService.login("javasyed", "javasyed")
 }
 then "the system returns a valid account",{
 account.getUserid().shouldBe "javasyed"
 account.getPassword().shouldBe "javasyed"
 }
}

is any problem in referring java classes in stories?

 

Regards,

Syed.

 

 

 

 

 

Ravi Hasija replied on Sat, 2009/11/07 - 11:54am

Hey Meera, Good work Meera! Do you have the project anywhere where it can be downloaded from? Thanks, Ravi

Meera Subbarao replied on Tue, 2009/11/10 - 6:45pm in response to: Ravi Hasija

Ravi,

I don't have the project. Sorry about that.

sridhar chidurala replied on Fri, 2010/03/05 - 11:19pm

Can I use easyb for integration tests? In my project we inject spring beans (including hibernate session factory) into the test case. can i do that with easyb?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.