0

I'm trying to run the test cases in a test class that I created but I'm getting the error:

Unexpected token 'private Class TestCreate'.

Here is the test class:

@isTest
private Class TestCreate{
    private static testMethod void runPositiveTestCases(){ 
        //Initial test to verify that all three available mailings are selected to be used to create campaigns
        System.debug('Verifying available mailings  ');

        List<Available_Mailings__c> availMailings = CreateCampaign.getAvailableMailings();
        Integer origIdsCount = availMailings.size();
        List<Available_Mailings__c> testAvailMailings = [SELECT Id , Create_Campaign__c , Name, Mailing_Type__c, Frequency__c FROM Available_Mailings__c WHERE Create_Campaign__c = TRUE];
        Integer testIdsCount = testAvailMailings.size();
        for(Available_Mailings__c amc_t : testAvailMailings){
            for(Available_Mailings__c amc : availMailings){
                if(amc.Id == amc_t.Id){
                   --origIdsCount;
                   --testIdsCount;
                }
        }
    }
    
       System.assertEquals(origIdsCount, 0);
       System.assertEquals(testIdsCount, 0);
        
        
        //To test campaigns inserted, manually derive column (mailing_id+ _ + campaigin_key)
        //and check against the variable Campaign_Key__c in the campaign model
        System.debug('Verifying campaign creation');
       CreateCampaign.upsertCampaigns();
        List<Campaign> campaigns = [SELECT Id , Campaign_Key__c FROM Campaign WHERE Campaign_Key__c <> ''];
       origIdsCount = availMailings.size();
       for(Available_Mailings__c amc : availMailings){
           for(Campaign cmp : campaigns){
               if(amc.Campaign_Key == cmp.Campaign_Key__c){
                   --origIdsCount;
               }
           }
       }
       System.assertEquals(origIdsCount, 0);
        
        //Test if the campaign members were added to the appropriate campaigns
        System.debug('Verifying addition of campaign members to campaigns');
        List<CampaignMember> members = CreateCampaign.addCampaignMembers();
        Integer numMembers = members.size();
        for(Mailings__C mc : members){
            for(Campaign cmp : campaigns){
                if(cmp.Mailing_ID__c == mc.Available_Mailing__C){
                    numMembers--;
                }
            }
        }
        System.assertEquals(numMembers, 0);
    }
}
    

        

What could be causing the issue?

EDIT: Error List

enter image description here

2
  • 1
    Do you mean you're getting that error when trying to save your class? That error wouldn't make any sense on trying to run the test. Also, how are you running your tests? The Developer Console sometimes has some weird results.
    – Adrian Larson
    Commented Feb 15, 2018 at 21:52
  • @AdrianLarson Yes, this error is showing up in the dev console when I try to save. And I'm not really sure how to actually run the tests. I haven't gotten that far yet lol Commented Feb 15, 2018 at 22:06

1 Answer 1

4

You have a number of obvious compile failures you need to work on. I suggest you work your way through some Trailhead modules to master the basic syntax of Apex.

Specific errors that you need to fix before your class has any hope of saving:

  • Using the incorrect API Name for an SObject:

    List<AvailableMailing> testAvailMailings = [SELECT ... FROM Available_Mailings__c WHERE ...];
    //   ^^^^^^^^^^^^^^^^            should be the same as      ^^^^^^^^^^^^^^^^^^^^^
    

    There is no AvailableMailing standard object. It looks like your type declaration should be List<Available_Mailings__c>.

  • Calling methods which don't exist. The only locally defined method is runPositiveTestCases, yet you call:

    • getAvailableMailings()
    • testAvailMailings()
    • upsertCampaigns()
    • addCampaignMembers()

    None of these methods are defined. If you defined them in SomeOtherClass, then you would need to call for example SomeOtherClass.upsertCampaigns().

4
  • Ok, yeah I guess I must have been rushing through writing the class. The issue is still there though. I just updated the post with the new code Commented Feb 15, 2018 at 22:28
  • @loremIpsum1771 Pretty sure that absolutely cannot be your only failure message. Please include all error messages verbatim.
    – Adrian Larson
    Commented Feb 15, 2018 at 22:36
  • I just added an image of the error list to the post. The only other error was with the scheduling of the class but that came after the initial error though Commented Feb 16, 2018 at 14:19
  • Yeah there were actually additional errors that showed up in the console. I had to cut the code from the file and paste it in and additional errors showed up. Commented Feb 16, 2018 at 17:47

Not the answer you're looking for? Browse other questions tagged .