dimanche 21 mars 2021

How to test void method with no parameters?

I have method that is called by another service and it just change one of the field for some rows in database. Method looks like this:

void errorOrders() {
    List<Orders> orders = OrderDAO.getErrorOrders(); //select only fields with status 'error'
    orders.forEach(order -> order.setStatus(OrderStatus.NEW);
    //some logging etc.
}

Is there any way to unit test this method? Can I inject myself inside this method and check if orders status was changed?

Cheers!

Aucun commentaire:

Enregistrer un commentaire