我正在尝试对生产中的顶点类进行简单的更改。我有适当的课程和适当的测试课程。测试类在沙箱中成功运行,没有错误,但显然错误来自 Salesforce 中的 TestHelper 默认测试类。当尝试在生产中部署时,它会抛出错误“方法不存在或签名不正确:来自 TestHelper 类型的 void createUser(Id, String, String, Date, Integer)”
我尝试了通常的方法,将其引用的方法更改为 public static void,但无济于事,它会在代码中引发错误
这是我的测试课:
@isTest
private class OppLineItemInvntryBO_AType_OppStge_Test {
@testSetup public static void setup() {
Profile p = [SELECT Id FROM Profile
WHERE Name = 'profile1' LIMIT 1];
Date myDate = Date.newinstance(2019,07,01);
User testUser = TestHelper.createUser(p.Id,
'company1','legalentity1',myDate,327001);
这是我的 TestHelper 类:
public with sharing class TestHelper {
public static User createUser(Id profileId, String company) {
Integer rnd = getRandomNumber(10000);
User user = new User(
Username = '[email protected]' + String.valueOf(rnd),
Email = 'john.doe' + String.valueOf(rnd) + '@acme.com',
LastName = 'Doe',
FirstName = 'John',
Alias = 'JD' + String.valueOf(rnd),
ProfileId = profileId,
LocaleSidKey = 'en_US',
LanguageLocaleKey = 'en_US',
TimeZoneSidKey = 'America/Los_Angeles',
EmailEncodingKey='UTF-8',
CompanyName = company);
insert user;
return user;
}
public static Integer getRandomNumber(Integer size){
Double d = math.random() * size;
return d.intValue();
}
}
完整的错误是这样的:
API 名称 - OppLineItemInvntryBO_AType_OppStge_Test 类型 - Apex 级 14号线 专栏 - 36 错误消息 - 方法不存在或签名不正确:来自 TestHelper 类型的 void createUser(Id, String, String, Date, Integer)
您正在 OppLineItemInvntryBO_AType_OppStge_Test 类中调用具有 5 个参数的 createUser 方法,其中与 TestHelper 类中一样,createUser 方法仅接受 2 个参数。这就是您收到此错误的原因。尝试使用正确的参数调用该方法。