You need to sign in to do that
Don't have an account?

Error: Compile Error: Defining type for testMethod methods must be declared as IsTest at line 17 column 33
Hi,
I am trying to Save an Apex Class. Please see below:
public class clsHelpSalesStages{
public List<OpportunityStage> getSalesStages(){
List<OpportunityStage> lstOppStage = [ SELECT MasterLabel,
IsClosed,
IsWon,
ForecastCategory,
ForecastCategoryName,
DefaultProbability,
Description
FROM OpportunityStage
WHERE IsActive = true
ORDER BY SortOrder ASC ];
return lstOppStage;
}
public static testMethod void testMyController(){
clsHelpSalesStages objOppStage = new clsHelpSalesStages();
List<OpportunityStage> lstOppStageTest = objOppStage .getSalesStages();
System.assert( lstOppStageTest.size() > 0 );
}
}
But I am getting the following error message: Error: Compile Error: Defining type for testMethod methods must be declared as IsTest at line 18 column 33
The Apex Class is used to show Opportunity Stages Description on the Home Page.
I can see that - The testMethod keyword is now deprecated, so therefore the error.
I have tried to use @isTest, but it didn't work.
I've never created an Apex Class before, unfortunately, so I am unable to correct the error message.
Could you please let me know what should I correct?
Thanks.
I am trying to Save an Apex Class. Please see below:
public class clsHelpSalesStages{
public List<OpportunityStage> getSalesStages(){
List<OpportunityStage> lstOppStage = [ SELECT MasterLabel,
IsClosed,
IsWon,
ForecastCategory,
ForecastCategoryName,
DefaultProbability,
Description
FROM OpportunityStage
WHERE IsActive = true
ORDER BY SortOrder ASC ];
return lstOppStage;
}
public static testMethod void testMyController(){
clsHelpSalesStages objOppStage = new clsHelpSalesStages();
List<OpportunityStage> lstOppStageTest = objOppStage .getSalesStages();
System.assert( lstOppStageTest.size() > 0 );
}
}
But I am getting the following error message: Error: Compile Error: Defining type for testMethod methods must be declared as IsTest at line 18 column 33
The Apex Class is used to show Opportunity Stages Description on the Home Page.
I can see that - The testMethod keyword is now deprecated, so therefore the error.
I have tried to use @isTest, but it didn't work.
I've never created an Apex Class before, unfortunately, so I am unable to correct the error message.
Could you please let me know what should I correct?
Thanks.
Since the class clsHelpSalesStages is used to show Opportunity Stages Description on the Home Page request you to remove the below entire code block from your class.
public static testMethod void testMyController(){
clsHelpSalesStages objOppStage = new clsHelpSalesStages();
List<OpportunityStage> lstOppStageTest = objOppStage .getSalesStages();
System.assert( lstOppStageTest.size() > 0 );
}
and try to save.
All Answers
Since the class clsHelpSalesStages is used to show Opportunity Stages Description on the Home Page request you to remove the below entire code block from your class.
public static testMethod void testMyController(){
clsHelpSalesStages objOppStage = new clsHelpSalesStages();
List<OpportunityStage> lstOppStageTest = objOppStage .getSalesStages();
System.assert( lstOppStageTest.size() > 0 );
}
and try to save.