Last active
August 29, 2015 14:22
-
-
Save oscartcy/828d497a0f12dbbb36d6 to your computer and use it in GitHub Desktop.
Testing exeception
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Foo up = new Foo( | |
| userId__c = u.Id, | |
| permissions__c = '[]' | |
| ); | |
| try { | |
| insert up; | |
| throw new TestException(); // force to run catch block if insert do not throw exception | |
| } catch (Exception e) { // catch exception from insert | |
| System.Assert(e.getMessage().contains('Foo already exist!')); | |
| } | |
| //custom exception declaration | |
| private class TestException extends Exception {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment