0
  1. コンソールからの入力ができません。

     @Test
            public static void abcde1() throws Exception
             {
                 Run1 run123=new run1();
    
                 ApplicationContext context = new ClassPathXmlApplicationContext(
                    "test-beans.xml");
       ServiceClient serviceClient = (ServiceClien)context.getBean("customer");
                 System.out.println(serviceClient);
                 run123.setup(serviceClient);//setup belongs to another class
             }   
    

    2.この関数は別の Run1 に属します (BufferRead はそこでのみ定義され、System.in を入力として受け取ります。

        public void setup(ServiceClient serviceClient) throws Exception {
    
         System.out.println("enter some ");     
    
        System.out.println("Enter the UserName the user wants to login With");
    String userName = bufferRead.readLine();
    System.out.println(userName);
        }
    

プログラムでは、testng.xmlを参照してこのテストを呼び出します

      <suiteXmlFiles>
           <suiteXmlFile>testng.xml</suiteXmlFile>
      </suiteXmlFiles>
4

1 に答える 1

0

EclipseIndigoを使用して以下をテストしました。

    @Test
    public void tests() throws Exception {    
        System.out.println("Please enter the text");
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        reader.readLine();
    }

そしてそれはうまくいきます。テストの実行時にコンソールを選択し、入力テキストを入力してリターンキーを押すだけです。

于 2012-08-28T12:40:36.797 に答える