This is an example of a script that will start Sauce Connect, run your tests, and then close Sauce Connect afterwards. It relies on Bash and is designed to wrap around Maven. You could replace mvn clean test with your own test framework's command and experiment with the results.
vendor/sauce-connect/bin/sc -u your_username -k your_access_key --pidfile pid > /tmp/sauce-connect-log.txt & sleep 1 while ! grep -m1 'Sauce Connect is up, you may start your tests.' < /tmp/sauce-connect-log.txt; do sleep 1 done echo Sauce-Connect is up and running mvn clean test …. kill $(cat pid)