First, let me say that I did not write most of the code below. I am trying to deploy additional Apex code and this code, written by my predecessor, is failing Apex tests when I try to deploy my change set to Production, apparently because "List has no rows for assignment to SObject".
So I hopped on Google and found this solution:
https://help.salesforce.com/HTViewSolution?id=000159853&language=en_US
which I tried to adapt to the code, but now I am getting an error message "Compile Error: Expression must be a list type: Engagement__c at line 21 column 21"
line 21 below is the line " testE = test E[0].Id; "
Can anyone guide me to a solution? Thanks in advance
@isTest(SeeAllData=true)
public class testBlockDuplicateTeamMembers {
static testMethod void testBlockDuplicateTeamMembers(){
Profile p = [SELECT Id FROM Profile WHERE Name='System Administrator'];
User u = new User(Alias='testUser', email='testUser@mycompany.com',
EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US',
LocaleSidKey='en_US', ProfileId = p.Id,
TimeZoneSidKey='America/Los_Angeles', UserName='testuser@mycompany.com', Can_Closed_Booked_Opportunities__c = TRUE);
insert u;
u = [SELECT Id FROM User WHERE UserName='testuser@mycompany.com' LIMIT 1];
System.runAs(u){
Engagement__c testE = [SELECT Id FROM Engagement__c WHERE Status__c = 'New' LIMIT 1];
if(testE.size() > 0)
testE = testE[0].Id;
SeeAllData=true
. Create your data.