samedi 23 janvier 2021

JUnit && Mockito

I have this method that I want to test

     private Connection con;
     private Statement set;
     private ResultSet rs;

     public void actualizarJugador(String nombre) {
            try {
                set = con.createStatement();
                set.executeUpdate("UPDATE Jugadores SET votos=votos+1 WHERE nombre " + " LIKE '%" + nombre + "%'");
                rs.close();
                set.close();
            } catch (Exception e) {
                // No modifica la tabla
                System.out.println("No modifica la tabla");
                System.out.println("El error es: " + e.getMessage());
            }
        }

How can I do it? How can I test a method that does not return anything?

Thanks

Aucun commentaire:

Enregistrer un commentaire