|
From: Jason S. <jsw...@ya...> - 2008-10-17 12:51:23
|
----- Original Message ----
From: YC <te...@gm...>
To: sim...@li...
Sent: Friday, October 17, 2008 12:32:54 AM
Subject: [Simpletest-support] Can simpletest print out the value that causes failure?
Hi all, I'm new to simple test.
I've a ValidationManager that has one function to validate names.
I've written testIsValidName to be:
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.
Hello, welcome to SimpleTest.
I might do something like:
$good_names = array(...);
$bad_names = array(...);
foreach($good_names as $test_name) {
$this->assertTrue($oVM->isValidName($test_name), $test_name.' should be valid');
}
foreach($bad_names as $test_name) {
$this->assertFalse($oVM->isValidName($test_name), $test_name.' should not be valid');
}
Regards,
Jason
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
|