You need to sign in to do that
Don't have an account?
SFAdmin5
test class question
Trying to figure out how to write test classes.
Gota simple one that just inserts a user record, then checks a list of collaborationgroupmember records to see if that inserted user record is assigned to a specific group.
When I run this test I get the following error. Looke like my list is empty but not sure why.
"System.AssertException: Assertion Failed: Expected: 1, Actual: 0"
He
@isTest private class Test_UserTrigger2 { static testMethod void testChatterAddGroup (){ Profile profile = [select Id from Profile where name = 'Standard User']; User u = new User(); u.LastName = 'TestLast45'; u.FirstName = 'TestFirst45'; u.Alias = 'Stest45'; u.Email = 'test45@test.com'; u.EmailEncodingKey = 'UTF-8'; u.LanguageLocaleKey = 'en_US'; u.LocaleSidKey = 'en_US'; u.CommunityNickname = 'Test45'; u.Primary_User_Location__c = 'Waltham'; u.TimeZoneSidKey = 'America/Los_Angeles'; u.ProfileId= profile.Id; u.Username = 'rosstesterx1234@constantcontact.com'; test.startTest(); insert u; test.stopTest(); List<CollaborationGroupMember> cgm = [SELECT id FROM CollaborationGroupMember WHERE CollaborationGroup.Name='Waltham' AND MemberId=: u.Id]; System.assertequals(1,cgm.size()); } }
re's the test that results in that error:
no that doesn't matter but thanks a lot for the response anyway.
I think I figured this out myself. Posting the final working code in case anyone else wants to use it. The purpose of this test class is to test whether a refactored trigger assigns a newly provisioned SF user to a specific chatter group. the trigger and class code are readily available on these boards and bob buzzard's blog, but a working test is not available out there
All Answers
Could it be that you have an extra space in you query?
Should it be:
Just a thought . . .
no that doesn't matter but thanks a lot for the response anyway.
I think I figured this out myself. Posting the final working code in case anyone else wants to use it. The purpose of this test class is to test whether a refactored trigger assigns a newly provisioned SF user to a specific chatter group. the trigger and class code are readily available on these boards and bob buzzard's blog, but a working test is not available out there