Yii Framework Forum: Behavior driven development in Yii - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Behavior driven development in Yii Integration with behat project Rate Topic: -----

#1 User is offline   xrx 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 11-November 09
  • Location:Bosnia And Herzegovina

Posted 17 February 2011 - 02:30 AM

Anyone that came from Ruby probably knows what is BDD, Cucumber and it's advantages over the plain unit tests. For the rest, BDD is way to test models AND controllers with easy to read "scenarios".
Great thing is that Cucumber (Ruby's BDD framework) is ported to PHP and it's called Behat . Example of working with behat can be checked here .

Anyone tried to integrate behat with Yii? I'm working with Yii for almost 2 years, and used it for several large projects so far. Currently, my team is preparing for another large project and we're thinking to make this integration ourselves. Any help (code or ideas) will be appreciated and we will of course share our integration (although cannot promise future maintenance)

Of course, it would be best if Yii team decide to make it since it woule be included in future versions of framework. That's why I put it in here :)

P.S. Symphony 2.0 will have Behat integrated...
0

#2 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,312
  • Joined: 04-October 10

Posted 17 February 2011 - 04:54 AM

Don't we have already a set of TDD (Test Driven Development) classes with Yii (ie CWebTestCase)? what is the difference between Behat or PHPUnit?

PS: Just curious... I have read Behat docs and is interesting but I do not see major diffferences
¿How long would it take for you to understand that you own nothing in this world?

www.ramirezcobos.com


Posted Image
0

#3 User is offline   xrx 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 11-November 09
  • Location:Bosnia And Herzegovina

Posted 17 February 2011 - 05:07 AM

View PostAntonio Ramirez, on 17 February 2011 - 04:54 AM, said:

Don't we have already a set of TDD (Test Driven Development) classes with Yii (ie CWebTestCase)? what is the difference between Behat or PHPUnit?

PS: Just curious... I have read Behat docs and is interesting but I do not see major diffferences


Difference is that Unit tests are testing only models, not how they are implemented in controllers. With behat, you test both controllers and models, otherwise you have to use selenium or similar (unreliable) tools to test controllers. Other differences are: test are easy to understand even for common people and you can use it as some kind of documentation, use cases for testers and etc. And to be honest, creating unit tests is boring even we denied this because it helps us a lot. Creating scenarios (tests in BDD) can be fun and when they are finished,they give you great overview on what needs to be done and in which order.
My advice is that you try BDD on simple examples (without Yii) and soon you'll see the difference
1

#4 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,312
  • Joined: 04-October 10

Posted 17 February 2011 - 05:17 AM

View Postxrx, on 17 February 2011 - 05:07 AM, said:

Difference is that Unit tests are testing only models, not how they are implemented in controllers. With behat, you test both controllers and models, otherwise you have to use selenium or similar (unreliable) tools to test controllers. Other differences are: test are easy to understand even for common people and you can use it as some kind of documentation, use cases for testers and etc. And to be honest, creating unit tests is boring even we denied this because it helps us a lot. Creating scenarios (tests in BDD) can be fun and when they are finished,they give you great overview on what needs to be done and in which order.
My advice is that you try BDD on simple examples (without Yii) and soon you'll see the difference


Very interesting... thank you very much for your explanation. If I have a deeper look I let you know, it doesn't seem very hard to have a go.
¿How long would it take for you to understand that you own nothing in this world?

www.ramirezcobos.com


Posted Image
0

#5 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 2,842
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 17 February 2011 - 10:33 AM

View Postxrx, on 17 February 2011 - 05:07 AM, said:

And to be honest, creating unit tests is boring even we denied this because it helps us a lot.


Can't agree more - but don't you still need to write the unit tests below BDD? Or did i get this wrong? I can't imagine that BDD auto generates unit tests for you :)



0

#6 User is offline   xrx 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 11-November 09
  • Location:Bosnia And Herzegovina

Posted 17 February 2011 - 10:53 AM

View PostMike, on 17 February 2011 - 10:33 AM, said:

Can't agree more - but don't you still need to write the unit tests below BDD? Or did i get this wrong? I can't imagine that BDD auto generates unit tests for you :)


You can create unit tests with behat as a part of scenario... check out link I posted before At the bottom of the page you can see assets presented in ascii-like table and of course given scenario will use those and create unit test for models
0

#7 User is offline   seb 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 181
  • Joined: 29-June 09

Posted 20 February 2011 - 12:51 PM

While searching for BDD and PHP found also this - Support for BDD and Stories in PHPUnit 3.3
1

#8 User is offline   xrx 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 11-November 09
  • Location:Bosnia And Herzegovina

Posted 20 February 2011 - 06:15 PM

View Postseb, on 20 February 2011 - 12:51 PM, said:

While searching for BDD and PHP found also this - Support for BDD and Stories in PHPUnit 3.3


I've look at it. I have to say - nice stuff. Too bad it's not powerful as behat. Still worth a look at it.
I also found PHPSpec which seems to be clone of RSpec (another BDD framework for ruby) but it is not stable yet.
0

#9 User is offline   intel352 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 191
  • Joined: 05-February 10
  • Location:Southport, NC

Posted 30 March 2011 - 02:12 PM

Sounds like a good suggestion. If PHPUnit is implementing a similar solution, would it be more backwards-compatible for Yii to stick with PHPUnit for BDD implementation?
Need live Yii support? - Join the #yii IRC channel on Freenode!
0

#10 User is offline   sensorario 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,143
  • Joined: 07-September 10
  • Location:Cesena (Italy)

Posted 09 February 2012 - 06:17 PM

I am installing Behat and I want to implement bdd and tdd.
ABMundi - The goal based social network
yii on abmundi: http://www.abmundi.c...?q=yiiframework
0

#11 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,894
  • Joined: 10-October 10
  • Location:Denmark

Posted 09 February 2012 - 06:20 PM

I might give it a go too - I really can't get the hang on TDD with PHPUnit..
Behat seems like a winner.
"Less noise - more signal"
0

#12 User is offline   sidewinder 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 161
  • Joined: 08-July 09
  • Location:Poland

Posted 10 February 2012 - 03:21 AM

I was really looking forward for PhpUnit Stories support. Unfortunately Mr. Bergmann decided not to support them any more. One thing that really scares me in Behat is the use of regex to match implementations:
/** @Given /^I am in a directory "([^"]*)"$/ */

Also, I was under the impression that, compared to php_unit, it requires a lots of additional steps to get going. A little bit like walking that way. :) Maybe that's because I didn't give it a lot time.
---------------------------------------------------------------------
"Never memorize what you can look up in books."
Albert Einstein
0

#13 User is offline   sensorario 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,143
  • Joined: 07-September 10
  • Location:Cesena (Italy)

Posted 10 February 2012 - 03:25 PM

And what if I need to test human actions like clicks or something like that? I am talking about a tool like Mink for Symfony 2.
ABMundi - The goal based social network
yii on abmundi: http://www.abmundi.c...?q=yiiframework
0

#14 User is offline   adamski 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 06-March 12

Posted 10 March 2012 - 02:07 PM

I'm really interested in this too. Just come to Yii from Rails, and my last project was using Cucumber (plus a bit of RSpec) for BDD. I found it so useful and made the whole process of development really flow, at the same time leaving a trail of meaningful tests which can be used at any time to test part or all of the system. Helps to make really solid apps without the worry of hidden bugs plus "user stories" that integrate with code.

Would love to see something like this for Yii... perhaps Behat can be integrated somehow?
0

#15 User is offline   Ivica 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 303
  • Joined: 25-May 11
  • Location:Serbia

Posted 15 March 2012 - 05:09 AM

Behat AND BDD for PHP sound more interesting then TDD development, and it would be good if Yii would support BDD in addition to current support for TDD development(unit tests).
Zurmo: Yii Powered Open Source CRM
zurmo.org
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users