[SalesForce] UNKNOWN_EXCEPTION -, portal account owner must have a role In Test class

I have a class where i have created portal user. when i am testing the functionality it works fine.
Problem occurs when writing a test class –

enter image description here

When writring the test class for business class method of portal user creation. its giving me the error.

Error –

enter image description here

Thanks

Your Reply will Highly appreciated

Best Answer

Have you linked the contact to the specific account in your code before calling method to create portal user?

I couldn't see contact linked with Account in your test method.

Add one more line in the code which inserts contact.

con.Accountid = acc.Id;

Please try.Hope that solves the issue!