I was given this test code on here, and I'm having some problems with it.
UPDATE : This is the current code with the static fix for generateTestUser()
public with sharing class AutoCreateSubsTriggerTest {
static testMethod void testAutoCreateSubs() {
// First, set up your test User.
User testUser = generateTestUser();
// Generate your position but don't perform DML yet
Contract_Overview__c contover = new Contract_Overview__c(Subsidiaries_On_Contract__c = testUser.Id);
// Start your test and insert your contract overview
Test.startTest();
insert contover;
Test.stopTest();
// Get the subs from the DB to ensure they were created
List<Subs_Serviced_On_Contract__c> subs = [SELECT
Id
FROM
Subs_Serviced_On_Contract__c
WHERE
Contract_Overview__c = :contover.Id
];
// There should be 1 interviewer because only one user ID was provided
System.assert(1, subs.size(), 'One sub object is expected');
}
private static User generateTestUser(){
// We use the System Admin profile because it will always be there
Profile sysAdmin = [SELECT
Id
FROM
Profile
WHERE
Name = 'System Administrator'
LIMIT 1
];
// Generate the user
User newUser = new User(
UserName = '[email protected]',
LastName = 'Test',
FirstName = 'Jane',
Email = '[email protected]',
phone = '555-555-5555',
MobilePhone = '555-555-5554',
Street = '123 Fake Street',
City = 'Los Angeles',
State = 'CA',
PostalCode = '12345',
CommunityNickName = 'unit.test',
Alias = 'abcd',
ProfileId = sysAdmin.Id,
emailencodingkey = 'UTF-8',
languagelocalekey = 'en_US',
localesidkey = 'en_US',
timezonesidkey = 'America/Los_Angeles'
);
// Insert that user
insert newuser;
return newuser;
}
}
....and now I'm getting that same type of error :
Save Error : Method does not exist or incorrect siganure: System.assert(Integer, Integer, String)
Save error: Method does not exist or incorrect signature: generateTestUser()
that is referencing this line (25) :
System.assert(1, subs.size(), 'One sub object is expected');
One other question, are these lines correct at the bottom :
insert newuser;
return newuser;
..or should they be :
insert user;
insert user;
Thanks for everything. I really appreciate the time & effort.