如何为从Soql语句提取的字符串创建测试类?

时间:2018-07-24 17:29:41

标签: salesforce apex soql

     //prevents crashing the sparkler server
     public string vUser(string uid) {
                User u = [select name, Alias, CommunityNickname, FederationIdentifier, Domain_Credential__c from user 
                          where Id = :uid]; 
                string uName = u.Domain_Credential__c.toLowerCase();
                if(uname == null || !u.Domain_Credential__c.contains('@') || uName.substringBefore('@').contains('.') || uName.escapeJava().contains('\\') || uname.contains('@gtech.com') || uname.contains('@igt.com') ) { //TKT-0931762 
                   system.debug('uname = '+uname);

                   ApexPages.Message myMsg = 
                       new ApexPages.Message(ApexPages.Severity.Error,
                                             'Domain Credential Error. Please log an SFDC Internal HelpDesk ticket with a screenshot. Thank you.');
                   ApexPages.addMessage(myMsg);
                   return 'Domain Credential Error. Please log an SFDC Internal HelpDesk ticket with a screenshot. Thank you.';

               }
            else
                return 'Correct'; 

我正在尝试测试错误消息,除apexpages.message mymsg之外的其他所有人都可以工作。...它在开发中很明显,我只是可以通过测试类来触发它...

所以我尝试插入用户数据.put,我在想也许要针对我要测试的触发器/类

tnoftit =新

我要测试的其余课程引用了多个对象(长433行,我不会在此处粘贴它)

0 个答案:

没有答案