Start Selenium RC Server Automatically

How can I automatically start and stop the Selenium RC server when running phpunit tests?

I thought I could create a little bash script that does something like this (doesn't work):

java -jar ~/bin/selenium-server-standalone-2.0b3.jar & phpunit --configuration suite.xml && killall java 

Is there really a way to do this right? So that the first line runs in the background, and the execution of the second block to completion.

Or is there another good way to do this? Does phpunit have a means to start the process first?

It seems to me that I need to fully automate this, because if I forget to start the server, phpunit will not even throw any errors, it will just skip the tests!

+4
source share
2 answers

Do you want to run a shell script, java or php code?

php code: exec ("/ file path / script.sh");

java code: Process p = Runtime.getRuntime (). exec (/ file path / script.sh);

for the bat file. and that the script contains the command to start the selenium server or directly execute the command to start the server. Please clarify your question and in what language ??????

+3
source

(Just for fun)

 TMPFILE=`mktemp` SELENIUMJAR=~/bin/selenium-server-standalone-2.0b3.jar bash -c "echo $$ && java -jar '${SELENIUMJAR}'" > "$TMPFILE" & sleep 0.1 pid=`head -1 < "$TMPFILE"` phpunit --configuration suite.xml kill "$pid" ; sleep 2 kill -9 "$pid" ; sleep 0.1 rm "$TMPFILE" 
+1
source

All Articles