0

I have an approval process for which the intial submitter who creates the opportunity is to be 'Raj'. When I write the test class for it I assign the opportunity owner using a soql query

op.owner = [SELECT Name FROM User where name = 'Raj' and isActive = true];

On running the test class it is printing that opportunity owner is assigned as Raj in debug log. But when it is checking with the approval process. It is showing the intial submitter as me. I dunno how to change the initial submitter for this approval process in apex test class.

Any Help is much appreciated!

Thank you, Prasanth

1 Answer 1

1

Although you've not provided your test class, it sounds like you're using seeAllData = true. If you've not specified a RunAs user, whomever is running the unit test will likely be the user that is shown as the one who submitted it for approval. If you want a specific user to do the submission, then you'll want to specify them as the RunAs User for the Unit Test. It's best to create those users within your test class so you'll have control over them and repeatability. You'll also be able to assert them in your results.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .