+ Start a Discussion
shinerajbshinerajb 

Test code for a class with list

what is the test code for this class with list ?

 

public class A_List
{
public void s()
{
List<Integer> myList = new List<Integer>();
Integer a;
myList.add(a);
Integer myNumber = myList.get(0);
}
}

Navatar_DbSupNavatar_DbSup

Hi,

Try the below code snippet as reference:

 

public class A_List

{

public void s()

{

List<Integer> myList = new List<Integer>();

Integer a;

myList.add(a);

Integer myNumber = myList.get(0);

}

 

static testMethod void testA_List()

{

A_List obj = new A_List();

obj.s();

}

}

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

shinerajbshinerajb

Hi

 

Its working,how can I check it with a value

jhansisridhar_2011jhansisridhar_2011

Hi,

 

Test code coverage is 100%

 

code snippet:

 

@isTest
private class TestA_List{
static Testmethod void TestA_List() {
 A_List gg=new A_List();
 gg.s();
system.debug('>>>>>>> value'+gg);
 } }

 You can check vaue by using system.debug(value gg);

 

Mark as solution , once it satisfy ur requirement.

Damien_Damien_

You can't test any values because everything you created is just a local variable to the method.