Most of the time its fine to test things out on your local machine and local installation of Postgres but often, you want more flexibility, the ability to quickly reset to a known starting point and the ability to try out different and more complex server architectures.
That is where Vagrant comes in. I use it to quickly set up Postgres clusters at different versions and different configurations.
You can find all of these in my repo at https://github.com/philmcc/postgres_clusters
For example here is a set up to allow you to set up a 3 node cluster with 1 leader and 2 followers all on postgres 9.4 and using replication slots: