Continuous integration setup using bitcoind regtest on travis-ci
v0.11.0 and after:

Check and make sure that your daemon version is v0.11.0 or greater. If it is, the generate method should work.

Pre v0.11.0:

The setgenerate true method should be used.

In a standard network (such as testnet or main), setgenerate true will turn mining on indefinitely. In regtest, it just mines one block. You can also do 

setgenerate(TRUE, 10)


To mine 10 regtest blocks. The second parameter is called the generation limit.