Closed azjezz closed 5 years ago
HackTest
would have to override all methods of Assert
in order to add assertion count ( and probably mark assert methods final ? )
class HackTest extends Assert {
...
/**
* Recursively sorts the two arbitrarily depth nested arrays and then checks
* that the contents of the two arrays are equal.
*/
<<__Override>>
final public function assertKeyAndValueEquals<Tk as arraykey>(
KeyedContainer<Tk, mixed> $expected,
KeyedContainer<Tk, mixed> $actual,
string $msg = '',
): void {
parnet::assertKeyAndValueEquals($expected, $actual, $msg);
$this->addAssertionCount(1);
}
...
}
I think I remember discussing this elsewhere, but I can't find it; we definitely do not want to couple assertions to hacktest. fbexpect
being a separate library is an intentional decision. While they're not entirely decoupled, we aim for it to be reasonably straightforward to use fbexpect from another testing framework, or to use another assertion library within hacktest, without there being a canonical one.
We also consider assertFoo()
generally to be less clear than expect($a)->toFoo()
, especially for error messages e.g. pytest assertEqual(a, b)
is largely equivalent to assertEqual(b, a)
in various language's *unit libraries
facebook/fbexpect
as a dependencyFacebook\FBExpect\Assert
onFacebook\HackTest\HackTest
HackTest::addAssertionCount(int $count): void
methodHackTest::getAssertionsCount(): int
methodaddAssertionCount()
without doing any assertions, hacktest shouldn't complain.example :
sum.hack
MathFunctionsTest.hack
expected output :