• Miguel Roa
  • NEWBIE
  • 0 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
Hi, I'm new in APEX and I've been told to fix this test class:
 
@Istest
Public class MillisecondBatchConvertController_Test{
public static testMethod void testBatch() {
       
    Team_Form__c tfCustom = new Team_Form__c();
    tfCustom = [Select Id from Team_Form__c LIMIT 1];
    List <PS_TF_Status_Track__c> stList = new List<PS_TF_Status_Track__c>();
    for(integer count = 0; count<=1; count++){
        PS_TF_Status_Track__c st = new PS_TF_Status_Track__c(Hours__c=count,Minutes__c=count,Days__c=count,Team_Form__c=tfCustom.Id);
     stList.add(st);}
       
        insert stList;
       
        Test.startTest();
        MillisecondBatchConvertController mbcCon=new MillisecondBatchConvertController();
        ID batchprocessid = Database.executeBatch(mbcCon,1);
        Test.stopTest();
    }
}


And I'm getting this error:

System.QueryException: List has no rows for assignment to SObject

I suppose this is because tfCustom.Id is empty but why is doesn't have any value?

Thanks in advance