Skip to content

Instantly share code, notes, and snippets.

@sfboss
Created November 5, 2022 03:07
Show Gist options
  • Select an option

  • Save sfboss/50f3b5ac5dd18e3c4a434293f96b7040 to your computer and use it in GitHub Desktop.

Select an option

Save sfboss/50f3b5ac5dd18e3c4a434293f96b7040 to your computer and use it in GitHub Desktop.
validates an exception happened
public static void testValidation() {
Boolean threwException = false;
try {
// magical test method logic here
} catch (Exception e) {
threwException = true;
Boolean expectedExceptionThrown = (e.getMessage().contains(validationString)) ? true : false;
system.AssertEquals(true, expectedExceptionThrown, e.getMessage());
}
system.assertEquals(true, threwException, 'No exception was thrown');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment