Skip to content

Commit 7a4e64d

Browse files
committed
fix: add try-catch to skip optional test cases
1 parent 1e458b3 commit 7a4e64d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

tests/JsonSchemaTestSuiteTest.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,16 @@ public function testTestCaseValidatesCorrectly(
3434
$this->loadRemotesIntoStorage($schemaStorage);
3535
$validator = new Validator(new Factory($schemaStorage));
3636

37-
$validator->validate($data, $schema);
37+
try {
38+
$validator->validate($data, $schema);
39+
} catch (\Exception $e) {
40+
if ($optional) {
41+
$this->markTestSkipped('Optional test case would during validate() invocation');
42+
return;
43+
}
44+
45+
throw $e;
46+
}
3847

3948
if ($optional && $expectedValidationResult !== (count($validator->getErrors()) === 0)) {
4049
$this->markTestSkipped('Optional test case would fail');

0 commit comments

Comments
 (0)