I am trying to find out how can I check what system printed out at some point of iteration during the while loop statement.
I have this method:
/**
 * This method counts how much money user inserted
 * If it is not enough to buy chosen cup size it asks user to insert more
 * Otherwise it checks if user does not need the change
 * and collects money to machine based on cup size price
 * This method gets the message from properties file by key identifies
 * add.more.money - if not enough money is in machine
 * user.paid.change - if user put too much to machine
 * user.paid - if user paid the exact amount of money
 * @param constantPrice  - cup size price
 * @return countMoney - how much user put to machine
 */
@Override
public String countMoneyForCupSize(double constantPrice) {
    // constant - price depending on cup size
    String countMoney = " ";
    double sessionMoney = 0;
    boolean flag = true;
    while(flag) {
        if(constantPrice > sessionMoney) {
            System.out.println(MessageFormat.format(prop.getProperty("add.more.money"), (constantPrice-sessionMoney)));
            double insertedCash;
            try {
                insertedCash = insertCash();
                sessionMoney = sessionMoney + insertedCash;
                if(insertedCash == 0) {
                    System.out.println(MessageFormat.format(prop.getProperty("end.procedure"), sessionMoney));
                    flag = false;
                }
            } catch (InvalidCoinException e) {
                System.out.println(e.getMessage());
            }       
        }
        else {
            double change = sessionMoney - constantPrice;
            String makeCoffeeText = makeCoffee();   
            if(change > 0) {
                countMoney = MessageFormat.format(prop.getProperty("user.paid.change"), makeCoffeeText, sessionMoney, change);
            }
            else {
                countMoney = MessageFormat.format(prop.getProperty("user.paid"), makeCoffeeText, sessionMoney);
            }
            collectMoney(constantPrice);
            flag = false;
        }
    }
    return countMoney;
}   
JUnit:
@org.junit.Rule
public final ProvideSystemProperty property1 = new ProvideSystemProperty("MoreEuro", "You need more: 0.5 euro");
@org.junit.Test
public void testCountMoneyForCupSize() {
    System.out.println("---------------- Count Money For Cup Size -----------------");
    double largePrice = 1.5;
    double mediumPrice = 1;
    double smallPrice = 0.75;
    try {
        when(machineSpy.insertCash()).thenReturn(1.0);
        assertEquals(machineSpy.countMoneyForCupSize(largePrice), System.getProperty("MoreEuro"));
    } catch (InvalidCoinException e) {
        System.out.println(e.getMessage());
    }
} 
So I want to be clear that If user inserted 1 euro he still needs to insert half a euro more.
 
     
    