1

I'm getting the following error when trying to save my test class for a schedulable class:

expecting a right parentheses, found 'Test'

Here's the main class:

global class deleteConvertedChatter implements Schedulable {
   global void execute(SchedulableContext SC) {

        FeedItem[] deleteFeedItems = [  SELECT Id FROM FeedItem 
                                        WHERE CreatedById = '005A0000006G0Bu' 
                                        AND Type = 'TrackedChange']; 
        try {
            delete deleteFeedItems;
        } catch (DmlException e) {
            // Process exception here
        }       

   }
}

And the test class:

@isTest
private class testDeleteConvertedChatter {

    Test.StartTest();

    deleteConvertedChatter sh1 = new deleteConvertedChatter();

    String sch = '0 0 23 * * ?'; 

    system.schedule('Test', sch, sh1); 

    Test.stopTest();

}

Any ideas why I'd be getting this error?

2 Answers 2

3

You need to declare a method.

Incorrect

@IsTest
private class testDeleteConvertedChatter {
    Test.startTest();
    // other stuff
}

Correct

@IsTest
private class testDeleteConvertedChatter
{
    static testMethod void test1()
    {    
        Test.startTest();
        // other stuff
    }
}
3

You need to create a test method, not just a class:

@isTest
private class testDeleteConvertedChatter {

    @isTest static void testMethod1(){
        Test.StartTest();

        deleteConvertedChatter sh1 = new deleteConvertedChatter();

        String sch = '0 0 23 * * ?'; 

        system.schedule('Test', sch, sh1); 

        Test.stopTest();
    }
}

You must log in to answer this question.

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