SitePoint Sponsor

User Tag List

Page 2 of 3 FirstFirst 123 LastLast
Results 26 to 50 of 59
  1. #26
    Ribbit... Eric.Coleman's Avatar
    Join Date
    Jun 2001
    Location
    In your basement
    Posts
    1,268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Im testing 1 product... and cleaning up a few things before it can go live... and another product is about 70% done.

    I do have a 3rd project just starting, so I think from reading a post above I shold write tests before the code.... What i've always done is just document before hand, something like

    PHP Code:
    class document {
        
    /**
         * Add a document to the database, blah blah
         *
         * @param array $data Data to be added to the database
         * @return bool
         */
        
    function addDocument$data ) { }

    So, really, I should do something like that and then write a test class for it, correct?
    Eric Coleman
    We're consentratin' on fallin' apart
    We were contenders, now throwin' the fight
    I just wanna believe, I just wanna believe in us

  2. #27
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I wouldn't bother with the comment. What does /* Add a document */ tell you that function addDocument() doesn't?

    What do you want the code to do?

    Once you know that, you write a test to make sure it does that

    Douglas
    Hello World

  3. #28
    Ribbit... Eric.Coleman's Avatar
    Join Date
    Jun 2001
    Location
    In your basement
    Posts
    1,268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's so I can generate API documentation once im totaly done with the project.. and since I work in a team of 3 or 4, I need to make documents available to them.

    It's much easier to look at API documentation than have to look at 400 different functions or classes or whatever
    Eric Coleman
    We're consentratin' on fallin' apart
    We were contenders, now throwin' the fight
    I just wanna believe, I just wanna believe in us

  4. #29
    SitePoint Guru BerislavLopac's Avatar
    Join Date
    Sep 2004
    Location
    Zagreb, Croatia
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Eric.Coleman
    It's so I can generate API documentation once im totaly done with the project.. and since I work in a team of 3 or 4, I need to make documents available to them.

    It's much easier to look at API documentation than have to look at 400 different functions or classes or whatever
    DougBTX's point is that you should include into the inline documentation only what you really need, i.e. everything that isn't already obvious. If your method is called addDocument() and is, say, passed a parameter $documentPath, there is very few additional information you may add to inline documentation -- any parsing tool will extract the method and param names, and your comment may be as simple as
    PHP Code:
    /**
     * @param    $documentPath    String.
     **/ 

  5. #30
    Ribbit... Eric.Coleman's Avatar
    Join Date
    Jun 2001
    Location
    In your basement
    Posts
    1,268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, i've got all this down...

    Is it to late to start even after the project is public? The stuff has been out a while, and I want to write tests now... that good, or is it easier to start with tests first?
    Eric Coleman
    We're consentratin' on fallin' apart
    We were contenders, now throwin' the fight
    I just wanna believe, I just wanna believe in us

  6. #31
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you want to write tests my man, write tests

    It just isn't as much fun writing tests for code you know works. How about writing tests for new code you write? Or, the next time you find an unexpected bug, try and test it to pieces rather than using echos or log files etc. That might be a better start than just saying "I've got some code that works, I'll write some tests to make sure it works", it is always more fun to know what it is you are trying to achieve when you do something

    Douglas
    Hello World

  7. #32
    Non-Member
    Join Date
    May 2005
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm just starting to get into patterns and test driven development, are tests basically just cut down versions of the final classes, i.e. the absolute core functionality of the class?

  8. #33
    SitePoint Guru dagfinn's Avatar
    Join Date
    Jan 2004
    Location
    Oslo, Norway
    Posts
    894
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    At the risk of seeming egotistical, here is the comment I just posted to the SimpleTest mailing list:

    As far as I'm concerned I gave up on PHPUnit because of a lack of documentation and lack of compatibility between versions. I used the pre-1.0 versions of PHPUnit and did fine with them. But I was unable to get version 1 to work. When Advanced PHP Programming appeared I tried copying the examples from the book, but it still didn't work. I simply couldn't figure out how to run the tests.

    What I generally do when I can't get open source software to work is to try an alternative. My experience is that trying to fix problems with poorly documented software is frequently more time-consuming than learning something else.

    I now use SimpleTest exclusively and don't know any good reasons why I would switch back.
    Dagfinn Reiersøl
    PHP in Action / Blog / Twitter
    "Making the impossible possible, the possible easy,
    and the easy elegant"
    -- Moshe Feldenkrais

  9. #34
    SitePoint Evangelist jplush76's Avatar
    Join Date
    Nov 2003
    Location
    Los Angeles, CA
    Posts
    460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have officially moved to simpleTest and havne't looked back
    My-Bic - Easiest AJAX/PHP Framework Around
    Now Debug PHP scripts with Firebug!

  10. #35
    Ribbit... Eric.Coleman's Avatar
    Join Date
    Jun 2001
    Location
    In your basement
    Posts
    1,268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    We need a simple test plugin for Eclipse..
    Eric Coleman
    We're consentratin' on fallin' apart
    We were contenders, now throwin' the fight
    I just wanna believe, I just wanna believe in us

  11. #36
    Non-Member
    Join Date
    Dec 2004
    Location
    Cluj
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Some concrete examples??
    I do not hove but i'm sure that you can find some here.

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

    Regarding Eclipse support, the Eclipse plug-in is currently being moved over to the SimpleTest web space. Watch this space...

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

  13. #38
    SitePoint Evangelist jplush76's Avatar
    Join Date
    Nov 2003
    Location
    Los Angeles, CA
    Posts
    460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Marcus, curious if there is anything that you haven't implemented in SimpleTest that you wanted to? Or is the project pretty much complete?
    My-Bic - Easiest AJAX/PHP Framework Around
    Now Debug PHP scripts with Firebug!

  14. #39
    simple tester McGruff's Avatar
    Join Date
    Sep 2003
    Location
    Glasgow
    Posts
    1,690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dalechristian
    I'm just starting to get into patterns and test driven development, are tests basically just cut down versions of the final classes, i.e. the absolute core functionality of the class?
    Sorry I missed this when you posted.

    Tests should explore the behaviour of the class. For example;

    PHP Code:
       class Greeter
       
    {
           function 
    greet()
           {
               return 
    'hello world';
           }
       }
       
           
    // would have a test method:
           
           
    function testGreet()
           {
               
    $greeter =& new Hello;
               
    $this->assertEqual($greeter->greet(), 'hello world');
           } 
    Of course that's a very simple example. If a Greeter class should respond differently to different users, you'd write a test for each case and check that the class produces the correct greeting for each user type. Every aspect of the class's desired behaviour should be explored in fine detail. With detailed tests, when something goes wrong the tests will tell you exactly where the problem is, thus making it very easy to fix.

    Assertions act as constraints on possible implementations of the class. Assert everything you have to, but no more than you have to since that can impede future refactorings.

  15. #40
    ********* 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 jplush76
    Marcus, curious if there is anything that you haven't implemented in SimpleTest that you wanted to? Or is the project pretty much complete?
    I am actually catching up on all of these things now. Mainly it's missing file uploading, which is a terribly accident prone area. The other one is running group tests in a separate process which will come in the release after the upcoming one.

    As for what I want to add two years after starting the project, mainly stronger HTML parsing so that I can do something like this if needed...
    PHP Code:
    class TestOfPhp5Stability extends WebTestCase {
    function 
    testCanIUpgradeNow() {
        
    $this->get('http://bugs.php.net/bugstats.php?phpver=5');
        
    $this->assertTableCell('Open''All',
                new 
    LessThanExpectation(100));
        }

    This moves SimpleTest from testing navigation and authorisation into testing the content of an application. After that probably JavaScript support, but I don't know how to do that yet.

    What would you say I am missing?

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

  16. #41
    SitePoint Evangelist jplush76's Avatar
    Join Date
    Nov 2003
    Location
    Los Angeles, CA
    Posts
    460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if you could integrate js unit testing as well that would be a super bonus, I'm currently looking into using JSUnit, but running/maintaining 2 seperate packages will get annoying I'm sure.
    My-Bic - Easiest AJAX/PHP Framework Around
    Now Debug PHP scripts with Firebug!

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

    I am very intersted in combining JSUnit and SimpleTest, probably by having JSUnit run the show. Harry Feucks is the man to ask about this, but he is rather tied up these days.

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

  18. #43
    ********* 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 Captain Proton
    I wish PHP Eclipse would support it...
    There is an alpha version of an Eclipse plug-in on the SF site right now. It would be great if you could try it out...
    http://sourceforge.net/projects/simpletest/

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

  19. #44
    SitePoint Guru
    Join Date
    Oct 2001
    Posts
    656
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'll get to work the next couple of days. I noticed you had it in CVS for a couple of weeks now.

  20. #45
    SitePoint Member
    Join Date
    Aug 2005
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    SimpleTest

    Hi to all

    I've installed your plugin SimpleTest for eclipse. I can see the "Result view" on my screen. But how should make it working ? Is it possible to have an exmple on how to use it ?
    Btw, i'm quite new with Eclipse and phpEclipse.

    regards,

    f.

  21. #46
    SitePoint Guru
    Join Date
    Oct 2001
    Posts
    656
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    there are some readme files in the plugins/...simpletest../ directory (don't know the exact name).

    I've been meaning to post the following for a while, but I kept forgetting:

    I gave the plugin a run and was able to run a test through it. The plugin is not very useful yet because it does not support group tests yet.

    I believe the plugin itself can be tested pretty well automatically by making some PHP files that are known to produce failing tests and then test to see that the plugin detects the test failure and displays the error correctly. I'll see if I feel like writing some JUnit tests

  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 Captain Proton
    I believe the plugin itself can be tested pretty well automatically by making some PHP files that are known to produce failing tests and then test to see that the plugin detects the test failure and displays the error correctly. I'll see if I feel like writing some JUnit tests
    Please send a mail to Steve as I know he is very keen to receive feedback right now.

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

  23. #48
    SitePoint Addict timvw's Avatar
    Join Date
    Jan 2005
    Location
    Belgium
    Posts
    354
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, i've tried it with eclipse3.1 and preview release of phpeclipse on php5. As documented, it didn't work.

    But I have an all_test.php file like (and all test cases are in the same directory)..

    PHP Code:
    require_once('../../../init.php');
    require_once(
    FRAMEWORK_EXT '/simpletest/unit_tester.php');
    require_once(
    FRAMEWORK_EXT '/simpletest/mock_objects.php');
    require_once(
    FRAMEWORK_EXT '/simpletest/reporter.php');

    $test = &new GroupTest('All file tests');
    foreach(
    glob('test_*.php') as $testfile)
    {
      
    $test->addTestFile($testfile);
    }

    if (
    TextReporter::inCli())
    {
      
    $test->run(new TextReporter());
    }
    else
    {
      
    $test->run(new HtmlReporter());

    All i have to do is the following: Click right on all_tests.php, choose run, choose PHP Application and fill in the path of the file. Then in the Arguments tab i enter the path of the file (instead of the default working directory). If i hit [Run] i get something like below in my console.. (Ok, most people like the green bar more..)

    Code:
    All file tests
    OK
    Test cases run: 1/1, Passes: 50, Failures: 0, Exceptions: 0

  24. #49
    SitePoint Addict chiefmonkey's Avatar
    Join Date
    Aug 2002
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just installed the simpletest plug-in but it doesn't seem to work. Eclipse says that it isn't installed.
    **Edit* Scratch that got it working now.*

    Just to go off on a slight tangent. What is everyone's PHP Plug in of choice. I use the Trustudio one just now. I haven't really looked at PHPEclipse.

    George
    Got Sig!

  25. #50
    SitePoint Evangelist
    Join Date
    May 2004
    Location
    Germany
    Posts
    550
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by chiefmonkey
    I just installed the simpletest plug-in but it doesn't seem to work. Eclipse says that it isn't installed.
    What version of eclipse are you using? i tried it with 3.1 SDK, 3.1, 3.0.1.
    With 3.1 SDK i got it working, but then i installed TruStudio (never used PHPEclipse too) and TruStudio wouldn't work. The other way round it was the same.

    But perhaps it's only me being stupid

    I'd really like to run tests with 1-2 mouseclicks, but having the choice between being able to use TruStudio XOR Simpletest Plugin i'd go for Trustudio


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
  •