dimanche 4 mars 2018

how can I test a void method that insert a record in database using Junit?

I hava a methods that calls another method to retrieve data and insert it into the database, how can I test this method in Junit since this method retrieve nothing?

public static void method(){ 


User user = getUser();


    try {

        String Query = "INSERT INTO users (USER_ID , Name) VALUES ("
         +user.getID()+","+user.getName()+")";


        Statement statement = conn.createStatement();
        statement.executeUpdate(Query);



    } catch (Exception e) {
        e.printStackTrace();
    }



}

Aucun commentaire:

Enregistrer un commentaire