title: Junit @ Test method, Giving input at runtime
body: <p>method written in my class </p>
  
  <pre><code>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')&amp;&amp;(ch!='Y'))
      {
          break;
      }
  
      }while(count&lt;=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&lt;=5));
  }
  </code></pre>
  
  <p>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 </p>