You need to sign in to do that
Don't have an account?
Electron
Unit Test for owner change trigger
I have a trigger works for changing the owner for related look-up object, and it works fine.
But I am confused by writint its test, I know test class shouldn't access a real data.
So I try let test class insert a user, but user needs profile, that's still real data, if I do so, I still feel strange for this kind test.
What I should do to test it?
You can't create Profile data in test method and each org will always have some profiles like Admin. So you can query data from profile using SOQL, that is totally okay.
You can use @isTest(seeAllData=false) to make sure you do not access org data.
All Answers
You can't create Profile data in test method and each org will always have some profiles like Admin. So you can query data from profile using SOQL, that is totally okay.
You can use @isTest(seeAllData=false) to make sure you do not access org data.
Sorry I forget to thank you.
I also found this piece code, that I feel valued and store in code repository