SitePoint Sponsor

User Tag List

Page 2 of 5 FirstFirst 12345 LastLast
Results 26 to 50 of 109
  1. #26
    ********* Victim lastcraft's Avatar
    Join Date
    Apr 2003
    Location
    London
    Posts
    2,423
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hi...

    Quote Originally Posted by ceefour
    BTW what is the main features of SimpleTest compared to PHPUnit[2] ?
    SimpleTest has mock objects and a web tester. PEAR::PHPUnit has test coverage support via. XDebug and is a more faithful clone ofJUnit.

    Quote Originally Posted by ceefour
    Why not make it an extension to PHPUnit?
    I tried. Why don't you have a go?

    Quote Originally Posted by ceefour
    I've never used any. Too busy coding, who the hell would have time to develop tests?
    So you don't test your code? Come back when you've got a real job.

    yours, Marcus
    Marcus Baker
    Testing: SimpleTest, Cgreen, Fakemail
    Other: Phemto dependency injector
    Books: PHP in Action, 97 things

  2. #27
    SitePoint Zealot ceefour's Avatar
    Join Date
    Feb 2005
    Location
    Bandung, Indonesia
    Posts
    138
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    >So you don't test your code? Come back when you've got a real job.
    --
    I expect the "other" developer would LEARN MY CODE and create tests and run them... then when an error happens report to me EXACTLY IN WHICH FILE, WHICH LINE, WHY, HOW, AND THE PATCH TO FIX THE BUG ALSO THE GUARANTEE THAT THE PATCH HAS BEEN TESTED THOROUGHLY

    Heheheheeeeeeeeeeeeeeeeeee ;-)

  3. #28
    ********* Victim lastcraft's Avatar
    Join Date
    Apr 2003
    Location
    London
    Posts
    2,423
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hi.

    Ok, I deserved that as i was a bit sharp.

    However you must at least look at your web page after you write some code right? How long does that take?

    yours, Marcus
    Marcus Baker
    Testing: SimpleTest, Cgreen, Fakemail
    Other: Phemto dependency injector
    Books: PHP in Action, 97 things

  4. #29
    simple tester McGruff's Avatar
    Join Date
    Sep 2003
    Location
    Glasgow
    Posts
    1,690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ceefour, I've found that testing, far from being a waste of time, makes me much more productive. I couldn't imagine working without it - one of the best things you'll ever learn.

  5. #30
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was never one for Unit Testing either, and of the view that it wouldn't be much benifit to me and a complete waste of time

    How wrong I was. I use it but still not enough What I want to do as suggested by TDD is to use Unit Testing in the design process it's self. Unit Testing is a tool and to use it in any other manner would be wrong, after what I've read of TDD that is...

    But I still shy away from it. Why??

  6. #31
    simple tester McGruff's Avatar
    Join Date
    Sep 2003
    Location
    Glasgow
    Posts
    1,690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You don't have to use testing as a design tool. It's still enormously useful just to create more robust, reliable classes.

    Take an app like phpBB. It's pretty much untestable (globals everywhere) but I can't help wondering if there would be the same frequency of critical updates if input validation related code was nicely encapsulated and properly tested. With testing, you can quickly see exactly what's being blocked, as specified in the test cases. It's very easy to add each new breed of nastiness to a test and much easier to refactor until it passes.

    Anyway, getting slightly OT. New features? How about automatic code generation to fix a breaking test..

  7. #32
    SitePoint Zealot ceefour's Avatar
    Join Date
    Feb 2005
    Location
    Bandung, Indonesia
    Posts
    138
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I never said testing made anything unproductive. I love the idea of testing, even more unit testing. But _personally_ I can never get it done properly because of my "business" (i.e., going to college, eating, surfing for some babe's picture gallery, and whatnot).

    About "looking at my page": well, yeah. Basically that's the most testing I do. I for some reason do a more "defensive" approach, i.e. trying to code everything early, putting documentation at all places, and having placeholders and stuff like that. I try to fix things before it happens. And when it doesn't work, I fix it. And when it works, I try to spend some few hours tingling (not really testing) before publishing it.

    And then after the few hours it got published on the Internet I'll start monitoring the error logs, which contains quite complete information including backtrace (of course) and some other whatnot like currently logged in user and session data.... The error logging mechanism has to be robust though, it'd be useless if the error logger itself bugs.

    Of course this only works for errors. But more subtle things like security holes, untested validation, wrong = for ==, etc. .... well.....

    All in all unit testing rocks (even though I never had the chance to use them).

  8. #33
    ********* Victim lastcraft's Avatar
    Join Date
    Apr 2003
    Location
    London
    Posts
    2,423
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hi...

    Quote Originally Posted by ceefour
    About "looking at my page": well, yeah. Basically that's the most testing I do. I for some reason do a more "defensive" approach, i.e. trying to code everything early, putting documentation at all places, and having placeholders and stuff like that. I try to fix things before it happens. And when it doesn't work, I fix it. And when it works, I try to spend some few hours tingling (not really testing) before publishing it.
    The smallest commercial project I am involved with right nowis about 25K lines of code and two other developers. The largest is 120K lines and five other developers. I do none of your stuff. If I did, I'd spend days "tingling" .

    Here is how I test a user logging in by looking at three pages, clearing my cookies and session data, and documentating the behaviour of the site. I would check this result again even after I change the code by even a few lines...
    PHP Code:
    class TestOfSignIn extends WebTestCase {
        function 
    testValidLogin({
            
    $this->get($this->getHomepage());
            
    $this->clickLink('Log in');
            
    $this->setField('name''Marcus');
            
    $this->setField('password','My secret');
            
    $this->clickSubmit('Log in');
            
    $this->assertWantedText('Welcome Marcus');
        }

    They accumulate and give confidence. Running about 100 tests per second is typical. I don't even notice the tingling .

    It even gets tested when I'm not in the office: on roll out, every night (once we get Rephlux working), on every server every 15 minutes if it's infrastructure (using a Nagios plug-in), by every other developer making a change, on check-in...and I don't have to do a thing.

    I spend my time designing (I am typing unit tests at the same time), formalising requirements with clients (and writing acceptance tests at the same time), object modelling, iteration planning and sundry automation (I prefer automated builds too) and coding.

    I don't spend my time testing (one click of the mouse is all I need).
    I don't spend my time deploying (one command line is all I need).
    I don't spend time tracking project progress (one click of the mouse is all I need).
    I don't spend time verifying code against requirements (one click of the mouse is all I need).
    I don't spend my time documenting the code (the unit tests do that for me and they don't lie).
    I don't spend my time writing requirements docs (the acceptance tests do that for me andthey don't lie).
    I don't waste time checking severs for dependencies (one click of the mouse is all I need).

    Oh, yeah. I don't even need to try to fix stuff "before it happens"as that's the test writing. It rather comes for free. In fact I don't even need to fix stuff unless its a design error. We change stuff all the time though...because we can.

    Quote Originally Posted by ceefour
    And then after the few hours it got published on the Internet I'll start monitoring the error logs, which contains quite complete information including backtrace (of course) and some other whatnot like currently logged in user and session data.... The error logging mechanism has to be robust though, it'd be useless if the error logger itself bugs.
    Arrrgh! What a life of drudgery . If I want to deploy I type in the server names and a few other parameters and come back after a cup of tea to read the messages. If it passed all of it's tests it's live, else it automatically rolls back. After that...I go home and put my feet up. I know it's working.

    Oh, we don't have error logs as we don't need them. I don't want to clutter the code with logging anyway as it just slows everyone else down. We only write the code we need. I work a four day week. Life is good.

    Quote Originally Posted by ceefour
    All in all unit testing rocks (even though I never had the chance to use them).
    It sounds like you cannot afford not to do it. You're life is hell.

    yours, Marcus
    Marcus Baker
    Testing: SimpleTest, Cgreen, Fakemail
    Other: Phemto dependency injector
    Books: PHP in Action, 97 things

  9. #34
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Off Topic:

    You must spread some Reputation around before giving it to lastcraft again.



  10. #35
    SitePoint Addict pachanga's Avatar
    Join Date
    Mar 2004
    Location
    Russia, Penza
    Posts
    265
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was scared at first on seeing lastcraft's green alien avatar next to "I expect the "other" developer would LEARN MY CODE..." message. Fortunately it was ceefour

  11. #36
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Off Topic:

    Quote Originally Posted by pachanga
    I was scared at first on seeing lastcraft's green alien avatar next to "I expect the "other" developer would LEARN MY CODE..." message. Fortunately it was ceefour
    I actually still think of Marcus as having a brown paper bag on his head


  12. #37
    ********* Victim lastcraft's Avatar
    Join Date
    Apr 2003
    Location
    London
    Posts
    2,423
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hi...

    Quote Originally Posted by sweatje
    I actually still think of Marcus as having a brown paper bag on his head
    I liked that one, but it got too popular .

    yours, Marcus
    Marcus Baker
    Testing: SimpleTest, Cgreen, Fakemail
    Other: Phemto dependency injector
    Books: PHP in Action, 97 things

  13. #38
    SitePoint Zealot ceefour's Avatar
    Join Date
    Feb 2005
    Location
    Bandung, Indonesia
    Posts
    138
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Phew... this is yummy. I like it.

    Really, I liked it a lot... I should have thought why I didn't just use unit tests since a few years ago. ;-) Gotta spend some time *STUDYING* the best practices of using unit tests and getting used to it.

    BTW, is there a "best practices" documentation/tutorial on unit tests...? I mean, not the one who showed you "this is how to create a test function and to check if it passes" with several variations, but the one who gave you real-world examples and typical solutions. Maybe more like the PHP Security Guide (http://phpsec.org), it doesn't give you "mysql_escape_string() escapes your data", but it gives you "You should put quotes around your data and escape them, using mysql_escape_string or any other appropriate function".

  14. #39
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Test Driven Development (Beck) would be a start if your learning. The Money example is very powerful example of what TDD is capable of

  15. #40
    SitePoint Zealot ceefour's Avatar
    Join Date
    Feb 2005
    Location
    Bandung, Indonesia
    Posts
    138
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dr Livingston
    Test Driven Development (Beck) would be a start if your learning. The Money example is very powerful example of what TDD is capable of
    Errr... free? (i.e. downloadable without requiring to fill any kind of form)

  16. #41
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ceefour
    Errr... free? (i.e. downloadable without requiring to fill any kind of form)
    Not unless your local library has a copy... unless you consider a library card as "filling a form"

  17. #42
    ********* Victim lastcraft's Avatar
    Join Date
    Apr 2003
    Location
    London
    Posts
    2,423
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hi...

    Quote Originally Posted by ceefour
    BTW, is there a "best practices" documentation/tutorial on unit tests...?
    Test Driven Development (by example) by Kent Beck is the main one. The other is just to wander around the C2 wiki.

    The depressing lack of PHP specific stuff caused me to write some. There is a tutorial on the lastcraft site and I wrote a quick one here: http://www.developerspot.com/tutoria...ent/page1.html. There may even be some PHPUnit stuff hidden away somewhere.

    Even Java is only now getting books on this; "JUnit in Action" and "Pragmatic Unit Testing".

    yours, Marcus

    p.s. Can I have my alien back now?
    Marcus Baker
    Testing: SimpleTest, Cgreen, Fakemail
    Other: Phemto dependency injector
    Books: PHP in Action, 97 things

  18. #43
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Errr... free?
    Strange...

    but the one who gave you real-world examples and typical solutions.
    Well, Becks book gives you a real world example, with documentation

  19. #44
    SitePoint Wizard
    Join Date
    Aug 2004
    Location
    California
    Posts
    1,672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There really is a dearth of information about Test Driven Development in PHP. For example I have read your excellent "Let us suppose we are testing a simple file logging class called Log" tutorial. But I have not found a PHP example of "Let us develop a logging class called Log using Test Driven Development." But that tutorial, and the logical extension of developing several related classes using TDD would be quite a large undertaking.
    Christopher

  20. #45
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As soon as I get done with the book, my next task is to write my presentations for php|tropics, one of which is TDD in php.

    I am toying with the idea of having some intro to SimpleTest stuff, and then opening up the subject to develop to the audiance and just working together to do TDD. Could be very challenging if things go wrong, but hopefully would be insightful.

    As always, slides will be available after the talk.

    Regards,
    Jason

  21. #46
    ********* Victim lastcraft's Avatar
    Join Date
    Apr 2003
    Location
    London
    Posts
    2,423
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hi...

    Quote Originally Posted by sweatje
    As soon as I get done with the book, my next task is to write my presentations for php|tropics, one of which is TDD in php.
    Sebastian Bergmann is thinking of writing a PHPUnit book and has just mentioned it on his blog. If you want to prod him further on this, why not drop a message in his comments? If enough people ask for it, it might push him into writing it.

    yours, Marcus
    Marcus Baker
    Testing: SimpleTest, Cgreen, Fakemail
    Other: Phemto dependency injector
    Books: PHP in Action, 97 things

  22. #47
    ********* Victim lastcraft's Avatar
    Join Date
    Apr 2003
    Location
    London
    Posts
    2,423
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hi...

    Quote Originally Posted by pachanga
    The only thing we're really missing is support for testing sequence of mock object methods calls....
    That's now been requested twice. I am taking a week or two off to reflect and then another to research the Ruby Test::Unit and Java JMock. After that I'll be branching the version 1 and building the next TODO. I'll add the expectSequence() feature to the mocks then.

    yours, Marcus
    Marcus Baker
    Testing: SimpleTest, Cgreen, Fakemail
    Other: Phemto dependency injector
    Books: PHP in Action, 97 things

  23. #48
    ********* Victim lastcraft's Avatar
    Join Date
    Apr 2003
    Location
    London
    Posts
    2,423
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hi...

    Quote Originally Posted by sweatje
    I am toying with the idea of having some intro to SimpleTest stuff, and then opening up the subject to develop to the audiance and just working together to do TDD. Could be very challenging if things go wrong, but hopefully would be insightful.
    Kent Beck does this. I would post a message to the TDD or XP mail lists (Yahoo groups) and ask about problems with this approach. You will certainly get some sort of response, and it's kinda nice to get one from Kent himself .

    yours, Marcus
    Marcus Baker
    Testing: SimpleTest, Cgreen, Fakemail
    Other: Phemto dependency injector
    Books: PHP in Action, 97 things

  24. #49
    SitePoint Zealot ceefour's Avatar
    Join Date
    Feb 2005
    Location
    Bandung, Indonesia
    Posts
    138
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by lastcraft
    Hi...



    Test Driven Development (by example) by Kent Beck is the main one. The other is just to wander around the C2 wiki.

    The depressing lack of PHP specific stuff caused me to write some. There is a tutorial on the lastcraft site and I wrote a quick one here: http://www.developerspot.com/tutoria...ent/page1.html. There may even be some PHPUnit stuff hidden away somewhere.

    Even Java is only now getting books on this; "JUnit in Action" and "Pragmatic Unit Testing".

    yours, Marcus

    p.s. Can I have my alien back now?
    Nice. You really prove you've that much time to spare (because of the productivity boost) as also to write a tutorial on it. That's very interesting!

    About the alien, actually I tried to find the ugliest icon that suits me best, but well, just to make you happy...

    From what I get, TDD is regarded as a matter that's quite "Advanced" for most (?) PHP programmers (definitely not all programmers, and definitely not for them in software engineering). I mean, learning the core PHP + object-oriented takes time. For sometime you keep reinventing the wheel without knowing it, then suddenly somebody suggests you use a database abstraction layer, use a templating engine, use PEAR, etc. etc. (including PHPUnit or SimpleTest, not to mention that security should've been first and foremost in the beginning) to most people this is overkill, even though these "suggestions" are actually to make their lives easier.

    Regarding software engineering... They didn't teach me this on my class. All they stuff were a bunch of document specifications (Software Testing Plan, etc.) and all these burdening stuff, but not something practical like this. It's like writing an extensive developer manual vs. marking up with PhpDoc (or any -Doc thingy). Agreedly it's arguable, but I've got to choose the one that does the job and is practical with minimal effort.

    I'll have to jump this train... really.

  25. #50
    SitePoint Zealot ceefour's Avatar
    Join Date
    Feb 2005
    Location
    Bandung, Indonesia
    Posts
    138
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm... after a bit of browsing it (TDD) seems to be very related to Extreme Programming and Agile Process (???). Heard of them awhile back in SE class but never got too intimate with it, actually with any software development process out there (RUP, ROPES, etc.).

    BTW the most common thing I face almost everyday is testing database-related activities, e.g. a user signing up, a user modifying his/her options, deleting a user (and ALL its related data, i.e. simulated cascaded updates/deletes because of using MySQL). This proves to be a bunch of hard and frustrating work.

    Can SimpleTest (or TDD in general) help me about this?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •