method written in my class
public static Advertisement[] createAd() throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
Advertisement[] ad = new Advertisement[5];
int count =0;
char ch;
do
{
System.out.println("Enter advertisement id:");
int id=Integer.parseInt(br.readLine());
System.out.println("Enter advertisement type:");
String type=br.readLine();
ad[count]= new Advertisement(id, type);
count++;
System.out.println("Do you want publish another advertisement(Y/N):");
ch = br.readLine().charAt(0);
if((ch!='y')&&(ch!='Y'))
{
break;
}
}while(count<=5);
if(count==5)
{
System.out.println("Maximum ads reached");
return ad;
}
return ad;
}
Juint @Test method
@Test
public void testCreateAd() throws IOException
{
Advertisement[] a = Advertisement.createAd();
assertTrue("Maximum five ads only should be created",(a.length<=5));
}
I want to check, createAd method should return max of 5 object of the type Advertisement. But when @Test method is running it's asking input, can we pass input to those readLine method through some where