我无法从控制台执行输入。
@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>
答案 0 :(得分: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();
}
它工作正常。只需在运行测试时选择控制台,输入输入文本并按返回键。