You need to sign in to do that
Don't have an account?
TCAdmin
Theory Assistance
Hello All,
I am having a difficult time understanding some of the testing features and how you would do them in theory. If I create a trigger/class that prevents a record from being save you can do an assert on the failed update/insert. What can you test on if you are doing something other than that? I am not understanding it in my head. If I have a trigger/class that sends out an email when a field gets modified, what would you test on? If you are doing an insert but can't figure out how it could possibly error out, what would the next step be to get your testing requirements?
I am having a difficult time understanding some of the testing features and how you would do them in theory. If I create a trigger/class that prevents a record from being save you can do an assert on the failed update/insert. What can you test on if you are doing something other than that? I am not understanding it in my head. If I have a trigger/class that sends out an email when a field gets modified, what would you test on? If you are doing an insert but can't figure out how it could possibly error out, what would the next step be to get your testing requirements?
For inserts/updates, there are a few ways to use the System.assert methods, this is a clip from a test I wrote. The trigger is designed to take the phone number from a Contact's parent Account and put it into the Contact's Phone field if the user left it null. The test verifies that that actually happens:
Make a test to show that the data WAS inserted. Maybe test for conflicting keys on Unique Contraints. Perhaps test for what should happen if the data being inserted already exists.
Thanks John,
I thought that I had missed something. The workflow rules would not work in this situation since the person getting notified is a couple objects away. Not the normal owner notification or field on the same object. Since these can't be tested, how would you get the test coverage required?