Yii Framework Forum: Using Of Fixtures/unit Testing - Yii Framework Forum

Jump to content

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

Using Of Fixtures/unit Testing Does somebody used? Rate Topic: -----

#1 User is offline   diggy 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 112
  • Joined: 18-November 09
  • Location:Ukraine, Khmelnitsky

Posted 04 November 2010 - 07:37 AM

Hi guys.

Just wanted to ask, does somebody used Yii built in unit testing option in real projects.

As for me, I never had used this option in my projects. But maybe I another kind of developer that not use unit testing.
0

#2 User is offline   Mike 

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

Posted 04 November 2010 - 08:47 AM

Add "rarely" and you can opt me in...

It might not be the wisest thing to do, but i have to admit writing good tests is often cumbersome and feels like doubling the effort required for a project. And if you decide to refactor, you have to refactor twice as much code. In the projects where i used tests i found, that i only had tests for the most obvious features. And writing tests for the rare tricky cases mostly wasn't easy.

Maybe i should have another look at the yii testing framework. From what i've read it should be much easier now to e.g. set up fixtures. Something i always found most tedious.
0

#3 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,450
  • Joined: 04-October 10

Posted 04 November 2010 - 07:05 PM

Hi there,

I have to say that I don't usually use (rarely as Mike said) testing in my projects. What I do is to code and check every block - variable (php-js) expected results, requests - responses speeds, but through firePHP, firebug and some time checking procedures (YSlow, etc...).

Once I am happy with it, I analyse again the code and try to find the best approach to use the fastest and cleanests algorithms.

After all that work, I don't feel like doing more tests to tell you the truth. I suppose I should, but that will be when the projects I am involved require a more specific 'care' on performance and results. Once that come I will get back on the subject.
¿How long would it take for you to understand that you own nothing in this world?

www.ramirezcobos.com
www.2amigos.us
www.github.com/tonydspaniard
www.github.com/2amigos


Posted Image
0

#4 User is offline   vario 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 36
  • Joined: 03-January 10

Posted 08 November 2010 - 08:15 AM

For me, this is a question of context & client requirements.

Working in the environment I do, the clients don't pay for testing; they pay for a website at the end of the day. So, I re-use code I know that works, which gives me confidence in the final implementation, so the testing has been done by previous implementations. So most of the websites I do may take a week (client dead-lines), and it'd prolong that process beyond that, hence unhappy clients. But, in those cases, the websites are so small, testing isn't that difficult to perform manually.

But I'm about to start developing a web-application (using Yii) that will be used as *the* core application a business to do their day-to-day work, and I want to offer a solid, tested solution. So in this case, where I have the luxury of time, and the need for it to be a solid application, I'll be using the Test Driven Development model for creating the application (as described in the Agile Web Application Development with Yii 1.1 and PHP5 book).

I'll get the reassurance that when it comes to adding new features and making bug fixes, I'll have the confidence in running the tests to know that we have locally in our development environment works and I can add new features without worrying. I'll also get the confidence to say to the client that the application works functionally based on the specifications we agree; no more, no less.

I look forward to working with the process, and while the initial learning curve will be painful (i.e. slow), it'll create a better application in the end.
0

#5 User is offline   Crazy Wizdom 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 08-September 10
  • Location:Brighton, UK

Posted 15 November 2010 - 07:47 AM

I use unit tests in every project. I rarely achieve 100% code coverage, but any nasty parts that look like they may be trouble, I *always* get tests in place around these.

Tests help me to re-factor and tweak client requirements more quickly and with more confidence.

Most importantly, they help me sleep well at night ;-)

dan
0

#6 User is offline   szako 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 56
  • Joined: 17-May 10

Posted 25 December 2010 - 07:20 PM

View PostCrazy Wizdom, on 15 November 2010 - 07:47 AM, said:

I use unit tests in every project. I rarely achieve 100% code coverage, but any nasty parts that look like they may be trouble, I *always* get tests in place around these.

Tests help me to re-factor and tweak client requirements more quickly and with more confidence.

Most importantly, they help me sleep well at night ;-)

dan


Totally agree with this.

I'm not really following the true TDD method, but I always write unit tests for models' methods. Because I'm using FAT model design, most of the logic is covered with tests.

Haven't used functional tests yet, needs to check that out too.
-------------
m(o_O)m
0

#7 User is offline   junxiong 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 541
  • Joined: 21-June 10

Posted 03 January 2011 - 10:47 AM

View Postszako, on 25 December 2010 - 07:20 PM, said:

Totally agree with this.

I'm not really following the true TDD method, but I always write unit tests for models' methods. Because I'm using FAT model design, most of the logic is covered with tests.

Haven't used functional tests yet, needs to check that out too.


Rarely do. Same reason with Mike. After knowing Yii, I just realize there is something called TDD to reduce buggy code. Since I am quite a sloppy programmer, I think I can use this TDD method to reduce the bugs. But what happened is, after coding the unit test, I've just realised there are a lot of bugs too in my test code and I just can't help but using more time to fix the unit test to make sure it doesn't buggy geez~ :(
Guess, I need to fix myself first before using TDD, or else it will take more time for me to write unit test.
“The most likely way for the world to be destroyed, most experts argue, is by accident. That’s where we come in; we’re computer professionals. We cause accidents.” - Nathaniel Borenstein

Yii Playground : Collaborative demo apps. You can join to improve it too!
My Team's Blog: In Indonesian.
0

#8 User is offline   szako 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 56
  • Joined: 17-May 10

Posted 06 January 2011 - 05:39 PM

I'm trying to follow TDD with my latest project, and all I can say It's good. When It comes to model's logic I always write the tests first. They give me confidence while coding.

Tho some days earlier I made bad test code, so It was buggy too :/ As you say ...

But the more I do it, the better I become, I hope. :)
-------------
m(o_O)m
0

#9 User is offline   mbi 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 604
  • Joined: 08-May 09

Posted 22 March 2011 - 04:00 PM

I m not doing TDD strictly, but I like working with fixtures and a test database, and I love this green bar in netbeans (Alt+F6). If you have some workflows, status changes, calculations etc, unit tests are a time saver at the end.
0

#10 User is offline   tof 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 29
  • Joined: 07-October 08
  • Location:Sophia Antipolis - French Riviera

Posted 14 March 2012 - 02:19 AM

I vote Rarely, because I only used unit and functionnal tests when I was contritubing to Prado.
But, I'm beginning a new project (very big project, complete rewrite of a huge VB.NET client/server application into a full web one), and I think I'll developp it with unit testing in mind...
So, I could vote "just starting" too.
0

#11 User is offline   Ben 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 270
  • Joined: 15-March 09

Posted 15 March 2012 - 08:42 AM

I guess a code generator to setup tests and fixtures would be helpful... However, it needed to take into account, that tests and fixtures would be re-generated again and again. And it needed a mechanism to keep the test code we implemented between those re-generate cycles...
Don't like ads in my sig...
0

#12 User is offline   Ivica 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 317
  • Joined: 25-May 11

Posted 21 March 2012 - 02:14 AM

I worked on four different Yii project, and on three projects we used unit tests. On my current zurmo project we have almost 1500 tests and almost 20000 asserts.
Check Zurmo Continuous Integration details.

Unit testing helps us much when we change some existing code, and make us confident that everything is working correctly after code changes. And unit tests can be used as additional documentation and examples how to use some classes/functions.
Zurmo: Yii Powered Open Source CRM
zurmo.org
0

#13 User is offline   IainG 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 14-December 11

Posted 02 February 2013 - 08:19 PM

Nearly always. I wouldn't dream of going back to the old, pre-TDD way, unless it was for an insanely simple project. Unit testing has cut my post-launch debugging time down by 95%, and it's also really improved the way I design my code.
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