Sometimes we have to crate user objects in tests & test methods. To crate a user we have to select a profile and set the required fields in the user objects as the apex code below.
Profile pfl = [select id from profile where name='Standard User'];
User testUser = new User(alias = 'u1', email='u1@testorg.com',
emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
localesidkey='en_US', profileid = pfl.Id, country='United States', CommunityNickname = 'u1',
timezonesidkey='America/Los_Angeles', username='u1@testorg.com');
Profile pfl = [select id from profile where name='Standard User'];
User testUser = new User(alias = 'u1', email='u1@testorg.com',
emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
localesidkey='en_US', profileid = pfl.Id, country='United States', CommunityNickname = 'u1',
timezonesidkey='America/Los_Angeles', username='u1@testorg.com');