Posts

Showing posts with the label test class

Salesforce Fact #859 | NetworkId error in ContentVersion record in test class

Have you encountered the error in test class: You do not have the level of access to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary: [NetworkId] This error is encountered while trying to insert a ContentVersion record. The insert fails because the NetworkId field is not set. To resolve this, query the NetworkId from the network Sobject using the below SOQL and set the same in the ContentVersion record before insert: Id networkId = [SELECT Id FROM Network LIMIT 1].Id; Reference:  https://salesforce.stackexchange.com/questions/325997/insufficient-access-on-cross-reference-entity-networkid

Salesforce Fact #851 | Test Suite in Apex test run

While dealing with code coverage coming from multiple test classes, Test Suite is a very helpful option. Using Test Suite, we can create a suite of multiple test classes as required and while checking the coverage we can simply run this suite instead of finding and running the test classes individually. To create a test suite: Go to Developer Console -> Test -> New Suite -> Enter a name for the suite -> Add the test classes from available to selected section -> save. To run a test suite:   Go to Developer Console -> Test -> New Suite Run -> Move the suite to selected test suites section -> Run suites. Reference:  https://help.salesforce.com/s/articleView?id=sf.code_dev_console_test_suites_creating.htm&type=5