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
Abel PalmaAbel Palma 

I need help with a test class

I'm a little confused here, I need to do a test class for cover this lines, but i don´t know how 
 
public class WebServiceController {
    public string selectedValue{get;set;}
    public void retrieveValue(){
        system.debug('Id del cliente' + selectedValue);       
        WebserviceClass.WebserviceClss(selectedValue);      	          
    }
}
I'm trying to do something like this, but I have errors.
public static testmethod void retrieveValueCtrllr(){
        //String selectedValue='D0000001';
        WebServiceController.selectedValue.set=('D0000001');
     	//WebServiceController.retrieveValue(selectedValue) ;
      
    }

 
 
Best Answer chosen by Abel Palma
Abel PalmaAbel Palma
I used this code and works nice
public static testmethod void retrieveValueCtrllr(){
        WebServiceController  obj = new WebServiceController();
        obj.selectedValue='D0000001';             
        obj.retrieveValue() ;
    }

 

 

All Answers

Amit Chaudhary 8Amit Chaudhary 8


Please try below code
public static testmethod void retrieveValueCtrllr(){
        //String selectedValue='D0000001';
        WebServiceController  obj = new WebServiceController();
        obj.selectedValue.'D0000001';
     	try
		{
			obj.retrieveValue(selectedValue) ;
		}Catch(Exception ee){
		}
    }

Let us know if this will help you

 
Amit Chaudhary 8Amit Chaudhary 8
Change line 04 like below
obj.selectedValue='D0000001';

 
Abel PalmaAbel Palma
ok, I'm trying that, but I have this error --------- Variable does not exist: selectedValue
Abel PalmaAbel Palma
I used this code and works nice
public static testmethod void retrieveValueCtrllr(){
        WebServiceController  obj = new WebServiceController();
        obj.selectedValue='D0000001';             
        obj.retrieveValue() ;
    }

 

 
This was selected as the best answer