At the time of writing the list of Reserved TLDs contains 4 different domains specifically for "Testing & Documentation Examples"
- .test
- .example
- .invalid
- .localhost
A subsection of the document also declares reserved second-level addresses:
- example.com
- example.net
- example.org
See [Reserved Top Level DNS Names)(http://tools.ietf.org/html/rfc2606) for more info
The crudest way is to make an entry in your /etc/hosts/ file, fortunately there are tools which can streamline this such as SwitchHosts
Another option is to install a local DNS server such as http://www.thekelleys.org.uk/dnsmasq/doc.html to
re-route for example all *.test
requests to localhost
See also Using Dnsmasq For Local Development On MacOS