algunos problemas relacionados con las pruebas
Frecuentes
Visto 178 veces
0
I am not able to perform the input from console.
@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.This function belongs to another Run1.(BufferRead is defined there only and it takes System.in as the input.
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); }
In program i m calling this test by referring to the testng.xml
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
1 Respuestas
0
I tested the following using 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();
}
and it works fine. Simply select the console when running the tests, type your input text and hit the return key.
Respondido 28 ago 12, 13:08
Yeah it works fine through Eclipse as i previously mentioned.The issue is when i run through pom.xml or through the command line it runs and asks for the first input and then does not go to the next statement. - user1629432
Its not working for me when i m running through maven(pom.xml).I guess Bufferreader is not working properly. - user1629432
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas java or haz tu propia pregunta.
Are you using the command-line? Are you using a DOS, bash or other shell? - Resh32
i m not able to get the output when i use the command line as well as the console present in the eclipse - user1629432
Why do you want to use console input in Unit tests in the first place? Unit tests are ment to be ran automatically as fast as possible. You may have hundrends of tests. - Piotr Gwiazda
I want to do so because i want to provide user the oppurtunity to tell me what he wants to do which i give in the form of a menu. - user1629432
This menu is actually a menu to perform various tests which i m doing by just calling those functions and not by testNG.For eg. if i want to create n no of tasks or something then the user will provide the value.The issue is not realted to @Test as i can use the main too to startup the program - user1629432