I have been using the Salesforce Security Scanner to scan my code:
http://security.force.com/security/tools/forcecom/scanner
Basically, the scan is telling me that I do not have any assert statements in my test class. It does not make any sense because I have several... and have even added in some pointless ones for further testing. Does anyone know why it might be showing up on the scanner?
@isTest
private class InactiveSalesRepControllerTest
{
static testMethod void testInactiveLeadReassignment()
{
User u = [SELECT Id FROM User WHERE Department = 'Sales' AND UserRole.Name IN :Constants.REP_ROLES AND CompanyName = 'Equity Trust' AND IsActive = true AND Id != :UserInfo.getUserId() LIMIT 2][1];
List<Lead> testLeads = new List<Lead>();
System.RunAs(new User(Id = UserInfo.getUserId()))
{
for(Integer i = 0; i < 3; i++)
{
Lead l = new Lead(FirstName = 'Test', LastName = 'Test', OwnerId = u.Id);
testLeads.add(l);
}
testLeads[2].Status = Constants.DORMANT_STATUS;
insert testLeads;
//testLeads[2].OwnerId = u.Id;
//update testLeads[2];
Task t = new Task(OwnerId = u.Id, Status = 'New', Subject = 'Test', WhoId = testLeads[0].Id);
insert t;
}
u.IsActive = false;
update u;
Test.startTest();
InactiveSalesRepController testMe = new InactiveSalesRepController();
System.RunAs(new User(id = UserInfo.getUserId()))
{
testMe.findLeads();
testMe.activeLeadsWithTasksReassign = 1;
testMe.activeLeadsWithoutTasksReassign = 1;
testMe.dormantLeadsReassign = 1;
testMe.selectedActiveRep = testMe.activeSalesReps[0].getValue();
testMe.assignLeads();
}
System.assert(true);
Test.stopTest();
//Had to remove the dormant parts because it is causing issues in production when we update the user after
//updating the Lead (Mixed DML)
List<Lead> leads = [SELECT OwnerId FROM Lead WHERE Id IN :testLeads AND Status != :Constants.DORMANT_STATUS];
for (Lead tLead: leads)
{
System.assertEquals(testMe.selectedActiveRep, tLead.OwnerId);
}
System.assert(2 == leads.size());
//For some reason the security scanner kept saying that there were no asserts even though there are 2 above this... so I added this
//to try to fix it.
System.assert(true);
}
}