How to detect integration tests running ?

How can I detect that test:unit integration tests are being run, so I can start/stop some background processes once for the duration of all the integration tests only, but not for unit / functional tests ?

Tests are run as a separate process, not connected to other ones, by default

So, using ps aux | grep i.e. for linux could help.

Anyway, you need OS based solution here

If you're running the test via rake, you could probably add a rake
task that starts whatever it is you are doing and add that task as a
dependency of test:integration, so that rake will invoke it before
test:integration runs

Fred