Swindon took the lead with a goal from Thomas Dossevi after only 8 minutes.
Nottingham Forest then pulled 2 goals back quickly. There goals were both scored by McLeary.
Then on the half hour mark Swindon equalised with a header from Dossevi making it 2-2.
Then in the second half an own goal was enough to give Swindon a 3-2 win.
Swindon will start to season on Saturday with a home game against Brighton.