function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
textualtextual 

chatter tests fail because see all data required for EVERY test??

i wanted to post a note to a chatter group for certain events and while the code works just fine on its own, when its coupled with all the exisiting tests THEY ALL FAIL because seeAllData is required to access chatter data?? so i need to edit EVERY SINGLE CLASS to mark see all data, which is not a best practice in my opinion because chatter groups cant see that a group exists until it tries to write a chatter group??


ridiculous
Andy BoettcherAndy Boettcher
You are correct, seeAllData is NOT best practice in any way, shape, or form in Unit Tests.  Have you tried creating your own Chatter post in your Unit Test and going against that?
textualtextual
im able to write a post, whats failing is looking for a group and / or creating one without the seeAllData flag. When I dont use see all data, I query the CollaborationGroup looking for a particular group, it doesnt find it, so i create a new entry but it fails due to Name being a duplicate. So it doenst exist, try to create it, and it fails becuase it exists..?? I hacked around it using Name + Timestamp and searching for like %name%, which im not very proud of...