You need to sign in to do that
Don't have an account?
jjvdev
OwnerId.IsActive = false after assignment to test lead
The code below runs successfully with no errors. The test leads ownerid and the activeuser Id are exactly the same.
So explain this to me???
15:44:36.155 (9155332602)|USER_DEBUG|[9]|DEBUG|***** user data *****User:{IsActive=true, Id=00517000000GYztAAG}
15:44:36.499 (9499882380)|USER_DEBUG|[15]|DEBUG|***** lead owner active *****false
How is the same user active in one query, but inactive in another???
So explain this to me???
15:44:36.155 (9155332602)|USER_DEBUG|[9]|DEBUG|***** user data *****User:{IsActive=true, Id=00517000000GYztAAG}
15:44:36.499 (9499882380)|USER_DEBUG|[15]|DEBUG|***** lead owner active *****false
How is the same user active in one query, but inactive in another???
@isTest private class UserIsActiveTest { static testMethod void myUnitTest() { // get active users List<User> reps = new List<User> ([select Id, IsActive from User where IsActive = true]); User activeuser = reps.get(0); system.debug ('***** user data *****'+reps.get(0)); // insert test lead and assign to active user Lead testLead = new Lead(LastName='Test1', Company='Test1 Inc.', Email='test1@test.com', Description='Description', OwnerId=activeuser.Id); insert testLead; system.assertEquals(activeuser.Id, testLead.OwnerId); system.debug ('***** lead owner active *****'+testLead.Owner.IsActive); } }
Hey you need to query from the test record to get the reference information .Also to use system.asset or assertEquals to test the record you need to query the record .Please try with below code it will work .
Please check the salesforce link test class best practice Verify the results are correct section .
https://developer.salesforce.com/page/How_to_Write_Good_Unit_Tests
Thnaks
Manoj
USER_DEBUG|[16]|DEBUG|***** lead owner active *****false
Updated version:
As the user we are getting from database that is why internally salesforce is making as false .
You can try with below code where I have created user in test context so it is showing true .
Please let me know any issue .