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 

getting errors writing simple test

sorry for the double posting, i posted in the wrong forum to start with

 

i'm working in the IDE and trying to write the simplest possible test

neither my class nor my test have been saved to the server

since it won't do that until i have the test

and the test has an error i can't figure out

 

 

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

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);

}

}

 

 

SamuelDeRyckeSamuelDeRycke

"i'm working in the IDE and trying to write the simplest possible test

neither my class nor my test have been saved to the server

since it won't do that until i have the test

and the test has an error i can't figure out"

 

Save it to the server, i'm amazed it is actually trying to run your test code without it being saved to the server. You can't execute code locally, it uses the API to communicate with the server to run your code, and get back the results as far as I know.