Heat the oil in an ovenproof pan over a medium heat, add the onion and cook for 8-10 minutes until the onion has caramelised, stirring occasionally to avoid sticking. Add the herbs and cook for a further minute.
Stir in the chopped tomatoes and black treacle until combined with the onion, then pour in the beans. Stir again to combine, then place the lid over the dish. Transfer the pan to the oven and bake for 30 minutes.
Remove from the oven and season with black pepper before serving.