Testing blockchain forks
You can use the invalidateblock RPC commands to create blockchain forks.

invalidateblock hash tells a node to consider hash invalid, so just generate a bunch of blocks, invalidate one somewhere down the chain on one of the regtest nodes, and have that node generate a bunch more to create a fork.

See qa/rpc-tests/mempool_resurrect_test.py in the Bitcoin Core tree for a python example.