my Test_Unit class passes @ 65% only, I'm not sure why is that?
Error message is:
BranchController_Test testBranchMethods System.QueryException: List has no rows for assignment to SObject Stack Trace: Class.TestData.CreateLead: line 122, column 1 Class.BranchController_Test.testBranchMethods: line 30, column 1
@isTest
private class BranchController_Test {
static testMethod void testBranchMethods() {
set<string> sZips = new set<string>();
set<id> sBranch = new set<id>();
//bBEGIN: S-444338 When wee run this test class we are getting Mixed DML Operations error, to avoid this we need modify this TEST Apex class
User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
system.runAs(thisUser){
//Branch__c b = TestData.CreateBranch(1, '99999');
Branch__c b = new Branch__c(name = 'Neil Test Branch');
insert b;
sBranch.add(b.Id);
ZipCode__c z = TestData.CreateZips('10001', b.Id);
insert z;
sZips.add(z.Name);
User u = TestData.CreateUser(1);
insert u;
IAASettings__c iaa = TestData.CreateSetting('DefaultOwnerId', u.Id);
insert iaa;
Account acct = TestData.CreateAccount(1, '10001');
insert acct;
Lead ld = TestData.CreateLead(1, '10001');
insert ld;
list<ZipCode__c> zipcodes = BranchController.LookupBranchByZip(sZips);
list<Branch__c> branches = BranchController.LookupOwnerByBranch(sBranch);
string branchAdd = BranchController.BranchAddress(b);
string acctAdd = BranchController.AccountAddress(acct);
string leadAdd = BranchController.LeadAddress(ld);
string nullString1 = BranchController.CheckForNull(acctAdd);
string nullStrin2 = BranchController.CheckForNull('null');
//BranchController.CalculateAccountDistance(b.Id, acct.Id);
}
}
}
Also i'm trying to fix the error in the Apex class,this method is the main reason of the errors. any help would help. thanks.