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
kentylerkentyler 

problem writing test

i'm trying to write the simplest possible test

my class

public  class GroupList

{

public string test;

public string gettest(){
    return 'test';
}
public void settest(string new_value){
    this.test = new_value;
}

}

 

my test

@isTest
public with sharing class testGroupList {

static testMethod void test_value_Test() {
    
           GroupList g = new GroupList();
           g.settest('test');
           string tv = g.gettest();   
        System.assertEquals('test',tv);

}
}

 

i get "method does not exist or incorrect signature on the "g.settest" line... can't figure out what i'm doing wrong

 

thanks

 

ken tyler

Best Answer chosen by Admin (Salesforce Developers) 
JitendraJitendra

Hi,

Your code is perfect.

 

i tried to execute it and found no problem.

 

public with sharing class GroupList {
	public string test;
	
	public string gettest(){
	    return 'test';
	}
	public void settest(string new_value){
	    this.test = new_value;
	}
}

 Test class

@isTest
public with sharing class testGroupList {
	static testMethod void test_value_Test() {
    
           GroupList g = new GroupList();
           g.settest('test');
           string tv = g.gettest();   
        System.assertEquals('test',tv);

}

}

 

 

 

All Answers

JitendraJitendra

Hi,

Your code is perfect.

 

i tried to execute it and found no problem.

 

public with sharing class GroupList {
	public string test;
	
	public string gettest(){
	    return 'test';
	}
	public void settest(string new_value){
	    this.test = new_value;
	}
}

 Test class

@isTest
public with sharing class testGroupList {
	static testMethod void test_value_Test() {
    
           GroupList g = new GroupList();
           g.settest('test');
           string tv = g.gettest();   
        System.assertEquals('test',tv);

}

}

 

 

 

This was selected as the best answer
SabrentSabrent

I too copied and pasted your exact code, executed without any errors with a code coverage of 100%.