You need to sign in to do that
Don't have an account?
kpeterson
Is it acceptable to raise errors in unit tests?
Is it acceptable to cause failures in a unit test when obtaining 100% coverage on code that raises an error on purpose? Like in the case that I have an insert trigger check to make sure another record doesn't already exists and it raises an error on the object if it does so it doesn't get inserted. This causes an error in the unit test because I intentionally cause the error to get 100% coverage. Is this against a unit test best practice or how do you get around this?
Edit: Here's an example:
I'm not 100% certain of the try/catch block offhand, as I'm a bit tired, but that's the general idea of a unit test.
Message Edited by sfdcfox on 12-05-2007 11:35 AM