Page MenuHomePhabricator

Extending testing functionality
Closed, WontfixPublic

Description

We should extend PhutilTestCase to include more PHPUnit-like functionality. Some discussion in T140.

Specifically, I think that the following would be useful:

  • Data providers
  • Some strong assertions such as assertInstanceOf.
  • Dependencies between tests (in PHPUnit this is achieved with the @depends annotation).

Event Timeline

joshuaspence raised the priority of this task from to Needs Triage.
joshuaspence updated the task description. (Show Details)
joshuaspence added a subscriber: joshuaspence.
epriestley claimed this task.
epriestley added a subscriber: epriestley.

I'm just going to close this because it doesn't identify any specific problems and I don't want to build these things to deal with hypothetical problems.

I'm fine with adding more behavior here, but I'd like to drive it by identifying things which are hard to test or hard to understand and then finding the best solution we can for those cases.

The only nitpick I have with tests currently is that this pattern (to test for a throw) is cumbersome:

$caught = null;
try {
  thing();
} catch (Exception $ex) {
  $caught = $ex;
}
$this->assertTrue($caught instanceof Exception);

...but I think the best solution for that involves closures, which we won't have until 2020 or so:

$this->assertThrows(
  'Exception',
  function() {
    thing();
  });

...and that's really just a small quality-of-life improvement.