Can simpletest print out the value that causes failure?

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

Post Reply
parka
Forum Commoner
Posts: 52
Joined: Mon Feb 26, 2007 6:48 am

Can simpletest print out the value that causes failure?

Post by parka »

Hi all, I'm new to simpletest.

I've a ValidationManager that has one function to validate names.

I've written testIsValidName to be:

Code: Select all

       function testIsValidName(){
           
            $oVM = new ValidationManager();
           
            $this->assertTrue($oVM->isValidName('john'));
            $this->assertTrue($oVM->isValidName('John'));
            $this->assertTrue($oVM->isValidName("john'dina"));
            $this->assertTrue($oVM->isValidName("john'Dina"));
            $this->assertTrue($oVM->isValidName("'dina"));
            $this->assertTrue($oVM->isValidName("dina'"));
            $this->assertTrue($oVM->isValidName('abcdefghijabcdefghij'));
           
            $this->assertFalse($oVM->isValidName('i'));
            $this->assertFalse($oVM->isValidName('koio9'));
            $this->assertFalse($oVM->isValidName('thisisaverylongnamemorethan20chars'));
           
        }
Is this the right way to go about it?

I was thinking of creating an array of names and then using foreach() to run through each name.
That will save me time from coding so many lines.
But the thing is when there's a failure, I won't know which line, hence value, causes the failure.

Thanks for any help in advance!
parka
Forum Commoner
Posts: 52
Joined: Mon Feb 26, 2007 6:48 am

Re: Can simpletest print out the value that causes failure?

Post by parka »

Opps. Solved it.

Apparently, just have to supply a second variable to assertTrue()
Post Reply