0
@isTest
public class ALN_Integration_BatchTest {
    public static testMethod void  metodoTest(){
        ALN_Integration__c rec = new ALN_Integration__c();            
        rec.First_Name__c = 'Kinder';
        rec.Last_Name__c = 'Lak';
        rec.Email__c = 'klak@gmail.com';
        rec.ALN_ID_Account_PMC__c = '001452';
        rec.Account_Name__c = 'KinderAccount';
        insert rec;   
        Test.startTest();
        Database.executeBatch(new ALN_Integration_Batch());
        Test.stopTest();
        
        ALN_Integration__c recAC = new ALN_Integration__c();            
        recAC.First_Name__c = 'AC_Test';
        recAC.Last_Name__c = 'ACln';
        recAC.Email__c = 'acln@gmail.com';
        recAC.ALN_ID_Account_AC__c = '001453';
        recAC.Account_Name__c = 'AC_rec_Test';
        insert recAC;
        
        List<Account> listAcc = [SELECT ID, Name from Account];
        system.assert(!listAcc.isEmpty());              
          
       
    }       
  • I don't think there's enough information here to really help you, please edit your question to include the class/method that you're trying to test. Testing boils down to making sure that you execute enough lines of code in your tests (coverage is determined by which lines of code get executed through a test), and that depends on the data that you set up in your test. If you want to execute a specific method, you need to ensure that you call that method. If you want to execute the lines of a specific if() statement, you need to set up test data to ensure that if condition is satisfied. – Derek F Sep 24 at 16:04
  • Your test class should likely have more than a single test method in it. Without getting too far into the nitty-gritty, if you have an if-else if-else, then you want to have one test to cover the if, a second test to cover the else if, and a third test to cover the else. – Derek F Sep 24 at 16:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.