samedi 24 janvier 2015

how to write test case for array which is initialized dynamically

How to write test case for this function using dynamically adding array values and getting the choice dynamically



public String xyz()
{
Scanner sc=new Scanner(System.in);
String arr[]=new String[20];
for(int i=0;i<10;i++)
{
int len = i+1;
System.out.println("enter Word "+len+":");
arr[i]=sc.nextLine();
}
System.out.println();
System.out.println();
System.out.println("Choose any of the following:");
for(int i=0;i<10;i++)
{
int len = i;
System.out.println("Choice "+i+": "+arr[len]);
}
System.out.println("Select a Choice: ");
int i=sc.nextInt();
return arr[i];
}

Aucun commentaire:

Enregistrer un commentaire