This question already has an answer here:

I'm trying to create some unit tests in Truffle to call functions in a contract as a different account, so I can properly test the contract. I can do this in javascript with { from: account } but I'd like to keep my tests in Solidity. How can I do it?

marked as duplicate by Thomas Jay Rush, benjaminion, tayvano, Dawny33, carver Aug 11 '17 at 0:37

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.