@isTest public with sharing class BidAnnouncementControllerTest { private static User setupUser(){ User u = new User(alias = 'manager', email='manager@acme.com', emailencodingkey='UTF-8', lastname='manager', languagelocalekey='en_US', localesidkey='ja_JP', profileid = System.Label.ProfileId_SystemAdmin, timezonesidkey='Asia/Shanghai', username='manager@acme.com' + Datetime.now().getTime(), ZongjianApprovalManager__c = UserInfo.getUserId() ); insert u; return u; } static testMethod void BidAnnouncementControllerTest() { // 询价 Opportunity opp = new Opportunity( Name='Opp', StageName='引合', CloseDate=Date.today(), CurrencyIsoCode = 'CNY' ); insert opp; // 中标通知书 Bid_Announcement__c ba = new Bid_Announcement__c( Opportunity_name__c = opp.Id, Status__c = '草案中' ); insert ba; User u = setupUser(); System.runAs(u){ BidAnnouncementController.BidAnnouncementController(ba.Id); BidAnnouncementController.ApplyFor(ba.Id); BidAnnouncementController.ConSent(ba.Id); BidAnnouncementController.Reject(ba.Id); BidAnnouncementController.UserInfo_Owner(); } } }