Simpletest woes

Discussion of testing theory and practice, including methodologies (such as TDD, BDD, DDD, Agile, XP) and software - anything to do with testing goes here. (Formerly "The Testing Side of Development")

Moderator: General Moderators

josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Simpletest woes

Post by josh »

Anyone noticing simpletest supresses typecasting errors? Anyone know whats involved in patching this / the easiest workarounds / alternative test frameworks?
User avatar
allspiritseve
DevNet Resident
Posts: 1174
Joined: Thu Mar 06, 2008 8:23 am
Location: Ann Arbor, MI (USA)

Re: Simpletest woes

Post by allspiritseve »

You can file a bug report here:

http://sourceforge.net/projects/simpletest/

Lastcraft is the person you want to talk to.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Simpletest woes

Post by josh »

Hmm well I'm not sure if its a bug per se. To clarify I think it only happens if a test fails, maybe its something you can override in the reporter class? I haven't looked into it in too much detail but its caught me off guard on a few occasions now
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Re: Simpletest woes

Post by Ambush Commander »

jshpro2, could you post a small test-case for your bug here? That would really help. :-)
lastcraft
Forum Commoner
Posts: 80
Joined: Sat Jul 12, 2003 10:31 pm
Location: London

Re: Simpletest woes

Post by lastcraft »

Hi...
jshpro2 wrote:Anyone noticing simpletest supresses typecasting errors? Anyone know whats involved in patching this / the easiest workarounds / alternative test frameworks?
Could you post a sample test?

SimpleTest has it's own error handler, but one that won't pick up E_STRICT errors (due to PHP 4 compatibility). You can get around this by pulling the SVN code, which is PHP 5 only and E_STRICT compliant.

assertEqual() does not throw on type errors. If you want type checking too, use assertIdentical().

yours, Marcus
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Simpletest woes

Post by Eran »

Marcus, is the trunk the PHP 5 compliant branch? you should push this on the site, I've been waiting for a PHP5 strict version of SimpleTest for ages.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Re: Simpletest woes

Post by Ambush Commander »

The trunk is PHP 5 E_STRICT compliant, yep. It has been for a while, actually.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Simpletest woes

Post by josh »

Ive been meaning to put together a test case for this, like I said its intermittent, I've kind of learned to live with it but next time it happens ( happens every few days ) I'll try to remember to cool down from my bug stomping session and figure out how to replicate this. I think it may be syntax errors ( "trying to invoke methods on non objects" ), maybe there's no way to catch those kinds of errors? If I remember I am getting a PHP error and no bar red OR green, and no type hinting errors, its as if simpletest is correctly catching the type error but then PHP is crashing out before ST can output the other error to the screen
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Re: Simpletest woes

Post by Ambush Commander »

It sounds like you're getting a segfault or exit is being called prematurely. Can you grep for exit/quit in your source code? Also check your logs.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Simpletest woes

Post by josh »

Although trivial, this illustrates the problem, like I said I've learned to deal with it, but its counter-intuitive because you sit there going "Well of course $foo is an instance of MyFoo or I would have gotten an error". I can affirmatively say it's gotten me more than once now. ( Other than that the library is great! ). Maybe also its impossible to trap "Fatal Errors"?

"Fatal error: Call to a member function bar() on a non-object in C:\Users\Josh\Desktop\ne8\metator\application\tests\Code\testTest.php on line 18"

Code: Select all

 
<?php
class testTest extends UnitTestCase
{
    function testMyTest()
    {
        MyTest::acceptFoo( NULL ); 
    }
}
 
class MyFoo
{
    public function bar() {}
}
class MyTest
{
    public function acceptFoo( MyFoo $foo )
    {
        $foo->bar();
    }
}
 
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Simpletest woes

Post by Eran »

It's definitely impossible to trap fatal errors, since by definition they are fatal to the script (kill it).
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Simpletest woes

Post by josh »

Yeah, but simpletest could catch the typecast error and throw its own fatal error first 8)
User avatar
allspiritseve
DevNet Resident
Posts: 1174
Joined: Thu Mar 06, 2008 8:23 am
Location: Ann Arbor, MI (USA)

Re: Simpletest woes

Post by allspiritseve »

Hmm... I wonder if I'm getting the same thing. I've been finding if I have syntax errors in the class I'm testing, the script quits at "All Tests" and doesn't show anything beyond that. It is quite annoying. I downloaded the latest trunk code, but that still doesn't change anything. Any ideas?

Code: Select all

class PaginationHelperTest extends UnitTestCase {
 
function setUp()    {
    $this->helper = new PaginationHelper();
}
 
function testDoNothing()    {
    $this->assertTrue (true);
}
 
}

Code: Select all

class PaginationHelper
 
}
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Simpletest woes

Post by josh »

Sounds different, never had that problem. Sounds like you have error reporting turned off
User avatar
allspiritseve
DevNet Resident
Posts: 1174
Joined: Thu Mar 06, 2008 8:23 am
Location: Ann Arbor, MI (USA)

Re: Simpletest woes

Post by allspiritseve »

jshpro2 wrote:Sounds different, never had that problem. Sounds like you have error reporting turned off
I don't... errors for the test case show up, but not the class under test.
Post Reply