Salesforce Apex触发零代码覆盖率

Salesforce Apex触发零代码覆盖率,salesforce,apex-code,apex,test-class,apex-trigger,Salesforce,Apex Code,Apex,Test Class,Apex Trigger,谁能帮我解决我的问题。 我已经用测试类创建了apex触发器。 测试运行后我没有收到任何错误,但无法获得任何代码覆盖率。 请检查下面是我的apex触发器和测试类 trigger getAllContacts on Scheme__c (after insert,after update) { List<ANZSIC_Contact__c> acc = new List<ANZSIC_Cont

谁能帮我解决我的问题。 我已经用测试类创建了apex触发器。 测试运行后我没有收到任何错误,但无法获得任何代码覆盖率。 请检查下面是我的apex触发器和测试类

                trigger getAllContacts on Scheme__c (after insert,after update) 
            {
                List<ANZSIC_Contact__c> acc = new List<ANZSIC_Contact__c>();
                for(Scheme__c scheme :trigger.new)
                {
                    Id devRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Underwriter').getRecordTypeId();
                    if(scheme.Account__c != null && scheme.Account__r.RecordTypeId== devRecordTypeId )
                    {
                        List<Contact> con = new List<Contact>();
                        con = [select Id,Email,Phone from contact where Account.Id =:scheme.Account__c];
                        for(Contact c:con)
                        {
                            acc = [select Id from ANZSIC_Contact__c where Contact__c =:c.Id and Scheme__c =:scheme.Id];
                            if(acc ==Null)
                            {
                                ANZSIC_Contact__c ac = new ANZSIC_Contact__c();
                                ac.Contact__c = c.Id;
                                ac.Scheme__c = scheme.Id;
                                ac.Email__c = c.Email;
                                ac.Phone__c = c.Phone;
                                acc.add(ac);
                            }
                            else
                            {

                            }
                        }
                        insert acc;
                    }
                }
            }

            @isTest(seeAllData=false)
            private class Test_getAllContacts
            {
                static testMethod void getAllContacts()
                {
                    test.startTest();
                    RecordType businessAccountRecordType = [SELECT Id FROM RecordType WHERE SobjectType='Account' AND Name = 'Underwriter'];
                    Account acc = new Account();
                    acc.Name = 'Test Account';
                    acc.RecordTypeId = businessAccountRecordType.Id;
                    insert acc;Contact con = new Contact();
                    con.LastName = 'Test data';
                    con.AccountId = acc.Id;
                    con.Email ='n@yahoo.in';
                    con.Phone = '987654321';
                    insert con; Scheme__c  sh = new Scheme__c();
                    sh.Account__c = acc.Id; 
                      test.stopTest();
                }
            }
触发方案c上的getAllContacts(插入后,更新后)
{
List acc=新列表();
for(Scheme\uu c Scheme:trigger.new)
{
Id devRecordTypeId=Schema.SObjectType.Account.getRecordTypeInfosByName().get('Undersider').getRecordTypeId();
if(scheme.Account\uu c!=null&&scheme.Account\uu r.RecordTypeId==devRecordTypeId)
{
List con=新列表();
con=[选择Id、电子邮件、联系人的电话,其中Account.Id=:scheme.Account\uuu c];
对于(联系c:con)
{
acc=[从ANZSIC_Contact_uuuc中选择Id,其中Contact_uuc=:c.Id和Scheme_uc=:Scheme.Id];
如果(acc==Null)
{
ANZSIC_触点_uuc ac=新的ANZSIC_触点_uuc();
ac.Contact_uuC=c.Id;
ac.Scheme\uu c=Scheme.Id;
ac.Email\uu c=c.电子邮件;
ac.Phone\uuu c=c.Phone;
acc.add(ac);
}
其他的
{
}
}
插入acc;
}
}
}
@isTest(请参阅AllData=false)
私有类测试\u getAllContacts
{
静态测试方法void getAllContacts()
{
test.startTest();
RecordType businessAccountRecordType=[从RecordType中选择Id,其中SobjectType='Account'和Name='Undersider'];
账户acc=新账户();
科目名称=‘测试科目’;
acc.RecordTypeId=businessAccountRecordType.Id;
插入acc;触点con=新触点();
con.LastName=‘测试数据’;
con.AccountId=acc.Id;
con.电子邮件地址:n@yahoo.in';
con.Phone='987654321';
插入con;Scheme__csh=新Scheme__c();
sh.Account\uuu c=会计科目Id;
test.stopTest();
}
}

也许我回答有点晚,但是

@isTest(seeAllData=false)
:如果将seeAllData设置为false,则查询不会获取测试类中的记录类型信息


将其设置为true,或者如果不允许,则在测试类中创建recordtype记录/数据。

无代码?证明必要的apex触发器和测试类无法在此处上载代码。复制,粘贴代码它给我的错误代码未格式化为代码。
                trigger getAllContacts on Scheme__c (after insert,after update) 
            {
                List<ANZSIC_Contact__c> acc = new List<ANZSIC_Contact__c>();
                for(Scheme__c scheme :trigger.new)
                {
                    Id devRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Underwriter').getRecordTypeId();
                    if(scheme.Account__c != null && scheme.Account__r.RecordTypeId== devRecordTypeId )
                    {
                        List<Contact> con = new List<Contact>();
                        con = [select Id,Email,Phone from contact where Account.Id =:scheme.Account__c];
                        for(Contact c:con)
                        {
                            acc = [select Id from ANZSIC_Contact__c where Contact__c =:c.Id and Scheme__c =:scheme.Id];
                            if(acc ==Null)
                            {
                                ANZSIC_Contact__c ac = new ANZSIC_Contact__c();
                                ac.Contact__c = c.Id;
                                ac.Scheme__c = scheme.Id;
                                ac.Email__c = c.Email;
                                ac.Phone__c = c.Phone;
                                acc.add(ac);
                            }
                            else
                            {

                            }
                        }
                        insert acc;
                    }
                }
            }

            @isTest(seeAllData=false)
            private class Test_getAllContacts
            {
                static testMethod void getAllContacts()
                {
                    test.startTest();
                    RecordType businessAccountRecordType = [SELECT Id FROM RecordType WHERE SobjectType='Account' AND Name = 'Underwriter'];
                    Account acc = new Account();
                    acc.Name = 'Test Account';
                    acc.RecordTypeId = businessAccountRecordType.Id;
                    insert acc;Contact con = new Contact();
                    con.LastName = 'Test data';
                    con.AccountId = acc.Id;
                    con.Email ='n@yahoo.in';
                    con.Phone = '987654321';
                    insert con; Scheme__c  sh = new Scheme__c();
                    sh.Account__c = acc.Id; 
                      test.stopTest();
                }
            }