You need to sign in to do that
Don't have an account?
Michael Johnson 29
Unit Testing: Set NetworkId of Running User
Is it possible to set the networkid of a running user in a unit test?
I created a test user in a unit test with a profile that only has access to 1 community. Running a test as this user using system.runas(user) still has network.getnetworkId() returning as null. I've tried setting the users networkId both using User.networkId = networkid and User.network.Id = networkid and neither work (invalid foreign key relationship). Is there somewhere in the test I can define what network to run the test under? Any other ideas?
I created a test user in a unit test with a profile that only has access to 1 community. Running a test as this user using system.runas(user) still has network.getnetworkId() returning as null. I've tried setting the users networkId both using User.networkId = networkid and User.network.Id = networkid and neither work (invalid foreign key relationship). Is there somewhere in the test I can define what network to run the test under? Any other ideas?
Let me know if it works.