Re: PHPUnit bug or feature?

From: Date: Sat, 15 Mar 2003 18:00:31 +0000
Subject: Re: PHPUnit bug or feature?
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-4250@lists.php.net to get a copy of this message
Sebastian Bergmann wrote:
Wolfram Kriesing wrote:
when calling assert*() twice within one test-method then this is only counted as one test. Is that right?
Yes.
Should it not be two tests?
No, only one assertion per test case makes sense.
sorry, but not always. I know the test are meant to be for testing things without depending on one another. But what if you want to test dependencies, it would not be bad enabling it. imagine this: function testAdd() {
    $num1 = new Number(10);
    $num2 = new Number(30);
    $this->assertEquals(40,$num1->add($num2));
    $this->assertEquals(70,$num1->add($num2));
} here you can see i do two test. the second call to $num->add() is also a real life test, since you can not ensure the software *never* calls add twice! and i dont see no sense in doing two tests like the following, only because PHPUnit doesnt allow it. function testAdd() {
    $num1 = new Number(10);
    $num2 = new Number(30);
    $this->assertEquals(40,$num1->add($num2));
} function testAdd1() {
    $num1 = new Number(10);
    $num2 = new Number(30);
    $num1->add($num2);
    $this->assertEquals(70,$num1->add($num2));
} Sorry but "only one assertion per test case makes sense." is not really enough reason :-) -- Wolfram ... translating template system ... http://os.visionp.de/modules/project/HTML_Template_Xipe ... authentication system .... http://sf.net/projects/auth ... and more at .... http://opensource.visionp.de

« previous php.pear.general (#4250) next »