I’m wondering why unittest systems like PHPUnit include what seems to be repetitive operators that just add overhead to the unit tests. I can understand a couple of those methods, but most seem like a total waste of time.
public function testPop(array stack)
{
this->assertEquals('foo', array_pop(stack));
this->assertEmpty(stack);
}
vs raw code (which is shorter and faster)
public function testPop(array stack)
{
this->assert('foo' == array_pop(stack));
this->assert(empty(stack));
}
Are these methods here for just so people that don’t understand the language they are programming in can still write unit-tests? I’m sure the authors of this projects are smarter than myself so there must be a reason.
These functions usually give more useful output. For example, an
assertEqualstest could tell you the expected and actual values, and that they were not equal.For example, the following code:
Will produce this output: