/** * This class contains unit tests for validating the behavior of Apex classes * and triggers. * * Unit tests are class methods that verify whether a particular piece * of code is working properly. Unit test methods take no arguments, * commit no data to the database, and are flagged with the testMethod * keyword in the method definition. * * All test methods in an organization are executed whenever Apex code is deployed * to a production organization to confirm correctness, ensure code * coverage, and prevent regressions. All Apex classes are * required to have at least 75% code coverage in order to be deployed * to a production organization. In addition, all triggers must have some code coverage. * * The @isTest class annotation indicates this class only contains test * methods. Classes defined with the @isTest annotation do not count against * the organization size limit for all Apex scripts. * * See the Apex Language Reference for more information about Testing and Code Coverage. */ @isTest private class InsReportPDFOuterControllerTest { static testMethod void myUnitTest() { Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin]; // ユーザー作成 User hpOwner = new User(Test_staff__c = true, Job_Category__c='销售服务' ,LastName = 'hp', FirstName = 'owner', Alias = 'hp', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); insert hpOwner; // 取引先作成 List rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院']; if (rectHp.size() == 0) { return; } Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'AccountCaseHistoryTestHp1', OwnerId = UserInfo.getUserId()); insert hp; Inspection_Report__c ir = new Inspection_Report__c(Name = '*', Hospital__c = hp.Id, Reporter__c = hpOwner.id ); insert ir; Inspection_Item__c ii = new Inspection_Item__c( Inspection_ReportId__c = ir.Id ); insert ii; PageReference page = new PageReference('/apex/InsReportPDFOuter?id=' + ir.Id); System.Test.setCurrentPage(page); InsReportPDFOuterController irpdf = new InsReportPDFOuterController(); irpdf.init(); irpdf.signStr = 'aaaaabbbbbccccc'; irpdf.saveSign(); irpdf.savePDF(); } }