function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ChiyanChiyan 

help me to write a test code

Public class Stage{
 List<Opportunity> ops;
 String[] Stage = new String[]{};
 Public String[] getStage(){
 return Stage;
 }
 
 Public List<SelectOption> getitems(){
 List<SelectOption> Options= new List<SelectOption>();
  options.add(new SelectOption('Closed Won', 'Closed Won'));
  options.add(new SelectOption('Closed Lost', 'Closed Lost'));
  options.add(new SelectOption('Qualification', 'Open'));
  return options;
  }
  
  Public void setStage(String[] Stage){
  this.Stage = Stage;
  }
  
 Public List<Opportunity> getOpp(){
    return ops;
   } 
 
 Public Pagereference Result(){
 ops = [select name, stagename, closedate from Opportunity where stagename =: Stage];
 return null;
 }
 
 
}
Raj VakatiRaj Vakati
Try this
 
@isTest
private class StageTest {
    static testMethod void myTest() {
        
        Account acc = new Account(Name = 'Morris and Ross');
        insert acc;
        Opportunity newOpp = new Opportunity(Name = 'newOpp',
                                             Type = 'New Customer',
                                             stageName='Prospecting',
                                             CloseDate=Date.Today(),
                                             AccountID = acc.id);
        insert newOpp;
        
        Stage s = new Stage();
        s.getStage();
        s.setStage(new String[]{'New'});
        s.getitems();
        s.getOpp();
        s.Result();        
    }
}