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

我使用 Eclipse Indigo 测试了以下内容:

    @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 回答