Skip to content

Commit

Permalink
MinkTestCase: move screenshot handling to onNotSuccessfulTest().
Browse files Browse the repository at this point in the history
  • Loading branch information
demiankatz committed Jan 31, 2024
1 parent b90df52 commit ce47aa5
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions module/VuFind/src/VuFindTest/Integration/MinkTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -1023,19 +1023,19 @@ public function setUp(): void
}

/**
* Standard teardown method.
* Hook for unsuccessful test runs.
*
* @param \Throwable $t Exception caused by test failure.
*
* @return void
* @throws \Throwable
*/
public function tearDown(): void
protected function onNotSuccessfulTest(\Throwable $t): void
{
// Take screenshot of failed test, if we have a screenshot directory set
// and we have run out of retries ($this->retriesLeft is set by the
// AutoRetryTrait):
if (
$this->hasFailed()
&& ($imageDir = getenv('VUFIND_SCREENSHOT_DIR'))
) {
if ($imageDir = getenv('VUFIND_SCREENSHOT_DIR')) {
$filename = $this->getName() . '-' . $this->retriesLeft . '-'
. hrtime(true);

Expand All @@ -1059,7 +1059,16 @@ public function tearDown(): void
file_put_contents($imageDir . '/' . $filename . '.png', $imageData);
}
}
parent::onNotSuccessfulTest($t);
}

/**
* Standard teardown method.
*
* @return void
*/
public function tearDown(): void
{
$htmlValidationException = null;
if (!$this->hasFailed()) {
try {
Expand Down

0 comments on commit ce47aa5

Please sign in to comment.