首页 > 解决方案 > Salesforce 包中的个人资料

问题描述

嘿,我在 2GP 中有以下代码:

        User u = new User(firstname= 'testPOWERBI',
            lastname='testPOWERBI',
            Alias='a',
            email = 'testPOWERBI@gmail.com',
            username= 'testPOWERBI@test.com',
            emailencodingkey='UTF-8',
            languagelocalekey='en_US',
            localesidkey='en_US',
            ProfileId = p.id,
            timezonesidkey='America/Los_Angeles');
        insert u;   
        system.runAs(u)
        {///what i need to do/// }

我的测试类在我的开发者控制台中以 100% 的测试覆盖率工作。但是当我创建包时,我收到以下错误:

Apex 测试失败:

 Class.PowerBIApp.LWC_DashboardTest.getAllDashboardTest: line 5, column 1 System.ListException: List index out of bounds: 0

第 5 行是:

profile p = [SELECT id, Name FROM profile where name = 'System Administrator'].get(0);

因此,我无法创建包。但是当我在没有 runas 的情况下进行测试时,我收到:

Apex Test Failure: Class.PowerBIApp.LWC_Dashboard.getAllDashboard: line 4, column 1
Class.PowerBIApp.LWC_DashboardTest.getAllDashboardTest: line 25, column 1 System.QueryException: Insufficient permissions: secure query included inaccessible field

如果有人可以帮助我???

感谢

标签: packagesalesforce

解决方案


推荐阅读