Set User Password Using Apex in Salesforce

Sample Code:

//Get User
User u = [SELECT Id From User Where Username = 'test@testuser.com'];
//Set Password
system.setPassword(u.Id, 'Pass@1234');