Good, I have a question for a test in JUnit . I do not know how to perform a test in my code that tells me that they can only enter a number in my textfield. I pass the code of what I have done.
@Test
public void testHandleSalir() throws Exception {
System.out.println("handleSalir");
ActionEvent event = null;
vistaController instance = new vistaController();
instance.handleSalir(event);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of inicializarTabla method, of class vistaController.
*/
@Test
public void testInicializarTabla() {
System.out.println("inicializarTabla");
vistaController instance = new vistaController();
instance.inicializarTabla();
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of initialize method, of class vistaController.
*/
@Test
public void testInitialize() {
System.out.println("initialize");
URL url = null;
ResourceBundle rb = null;
vistaController instance = new vistaController();
instance.initialize(url, rb);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
Now I have to validate only in the note textfiel that only numbers are integrated:
private void actualizartxfNota(String text){
if((Integer.parseInt(txfNota.getText())>0)&&
(Integer.parseInt(txfNota.getText())<=10)){
}
else{
System.out.println("BtAbrirDialogo ActionEventHandler");
// Creamos un tipo de dialog Alerta
Alert alert = new Alert(AlertType.ERROR);
// Establecemos el título
alert.setTitle("Diálogo de alerta");
// Establecemos el texto que aparece en la cabecera
alert.setHeaderText("Alerta");
// Establecemos el título que aparece en el cuerpo del diálogo
alert.setContentText("Introducir numero del 0 al 10");
// Mostramos el diálogo
alert.show();
txfNota.setText("");
}
}
Thanks and best regards